go-wrap-to-percent-w
converts legacy github.com/pkg/errors.Wrap(err, "foo")
to modern Go-native fmt.Errorf("foo: %w", err)
introduced in Go 1.13.
Input | Output |
---|---|
errors.Wrap(err, "foo") |
fmt.Errorf("foo: %w", err) |
errors.Wrapf(err, "foo %s %d", s, d) |
fmt.Errorf("foo %s %d: %w", s, d, err) |
errors.Errorf("foo %s %d", s,d) |
fmt.Errorf("foo %s %d", s, d) |
import "github.com/pkg/errors" |
import "errors" |
Unsupported functions and types: Cause, WithMessage, WithMessagef, WithStack, Frame, StackTrace
go get github.com/AkihiroSuda/go-wrap-to-percent-w
go-wrap-to-percent-w -w *.go
Flags:
-w
: write result to (source) file instead of stdout (Default: false)-gofmt
: rungofmt
after conversion (Default: true)
TODO: support specifying package names (./...
)