Skip to content

Commit

Permalink
refactor: replace hashicorp multierror with new go stdlib errors feature
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Feb 24, 2023
1 parent 71561c6 commit c54dba5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/templ/fmtcmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package fmtcmd

import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"time"

"github.com/a-h/templ/cmd/templ/processor"
parser "github.com/a-h/templ/parser/v2"
"github.com/hashicorp/go-multierror"
"github.com/natefinch/atomic"
)

Expand Down Expand Up @@ -46,7 +46,7 @@ func formatDir(dir string) (err error) {
var successCount, errorCount int
for r := range results {
if r.Error != nil {
err = multierror.Append(err, fmt.Errorf("%s: %w", r.FileName, r.Error))
err = errors.Join(err, fmt.Errorf("%s: %w", r.FileName, r.Error))
errorCount++
continue
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/templ/generatecmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package generatecmd
import (
"bufio"
"context"
"errors"
"fmt"
"os"
"runtime"
Expand All @@ -14,7 +15,6 @@ import (
"github.com/a-h/templ/cmd/templ/visualize"
"github.com/a-h/templ/generator"
"github.com/a-h/templ/parser/v2"
"github.com/hashicorp/go-multierror"
)

type Arguments struct {
Expand Down Expand Up @@ -56,7 +56,7 @@ func processPath(path string, generateSourceMapVisualisations bool, workerCount
var successCount, errorCount int
for r := range results {
if r.Error != nil {
err = multierror.Append(err, fmt.Errorf("%s: %w", r.FileName, r.Error))
err = errors.Join(err, fmt.Errorf("%s: %w", r.FileName, r.Error))
errorCount++
continue
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/templ/migratecmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package migratecmd

import (
"bytes"
"errors"
"fmt"
"reflect"
"strings"
Expand All @@ -10,7 +11,6 @@ import (
"github.com/a-h/templ/cmd/templ/processor"
v1 "github.com/a-h/templ/parser/v1"
v2 "github.com/a-h/templ/parser/v2"
"github.com/hashicorp/go-multierror"
"github.com/natefinch/atomic"
)

Expand Down Expand Up @@ -42,7 +42,7 @@ func processPath(path string) (err error) {
var successCount, errorCount int
for r := range results {
if r.Error != nil {
err = multierror.Append(err, fmt.Errorf("%s: %w", r.FileName, r.Error))
err = errors.Join(err, fmt.Errorf("%s: %w", r.FileName, r.Error))
errorCount++
continue
}
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/a-h/pathvars v0.0.12
github.com/a-h/protocol v0.0.0-20230224160810-b4eec67c1c22
github.com/google/go-cmp v0.5.9
github.com/hashicorp/go-multierror v1.1.1
github.com/natefinch/atomic v1.0.1
github.com/rs/cors v1.8.3
go.lsp.dev/jsonrpc2 v0.10.0
Expand All @@ -19,7 +18,6 @@ require (

require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/segmentio/encoding v0.3.6 // indirect
go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 // indirect
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
Expand Down

0 comments on commit c54dba5

Please sign in to comment.