Skip to content

Instantly share code, notes, and snippets.

@alexandear
Created February 27, 2025 12:40
Show Gist options
  • Select an option

  • Save alexandear/b72e5932f411dd1fef9e1c4d2e36f2ef to your computer and use it in GitHub Desktop.

Select an option

Save alexandear/b72e5932f411dd1fef9e1c4d2e36f2ef to your computer and use it in GitHub Desktop.
Convert github.com/pkg/errors to errors
# Update `errors.Wrapf`:
find . -name "*.go" -exec sed -i '' -E 's/errors\.Wrapf\(([^,]+), "([^"]+)", ([^)]+)\)/fmt.Errorf\("\2: %w", \3, \1\)/g' {} +
# Update `errors.Wrap`:
find . -name "*.go" -exec sed -i '' -E 's/errors\.Wrap\(([^,]+), "([^"]+)"\)/fmt.Errorf\("\2: %w", \1\)/g' {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment