Skip to content

Instantly share code, notes, and snippets.

@pgaskin
Created September 3, 2019 19:47
Show Gist options
  • Select an option

  • Save pgaskin/21d06545d1d4a3b82871ecc80bd40307 to your computer and use it in GitHub Desktop.

Select an option

Save pgaskin/21d06545d1d4a3b82871ecc80bd40307 to your computer and use it in GitHub Desktop.

Regexps for replacing old error stuff with Go 1.13-style things.

  • github.com/pkg/errors.Wrapf: errors\.Wrapf\(([^,]+), ("[^"]+)", ([^)]+)\) -> fmt.Errorf($2: %w", $3, $1)
  • github.com/pkg/errors.Wrap: errors\.Wrap\(([^,]+), ("[^"]+)"\) -> fmt.Errorf($2: %w", $1)
  • fmt.Errorf %v: (fmt\.Errorf\("[^"]+: )%v(", [^)]+\)) -> $1%w$2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment