go-wrap-to-percent-w

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

go-wrap-to-percent-w: convert Wrap(err, "foo") to Errorf("foo: %w", err)

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.

Conversion rule

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

Install

go get github.com/AkihiroSuda/go-wrap-to-percent-w

Usage

⚠ Backup your data before conversion

go-wrap-to-percent-w -w *.go

Flags:

  • -w: write result to (source) file instead of stdout (Default: false)
  • -gofmt: run gofmt after conversion (Default: true)

TODO: support specifying package names (./...)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL