Skip to content

Instantly share code, notes, and snippets.

@zchee
Forked from Peltoche/go_1.13_error_migration.bash
Created October 16, 2019 07:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zchee/ce0720f505fc6b9f9b54d8c355d5e37d to your computer and use it in GitHub Desktop.
Save zchee/ce0720f505fc6b9f9b54d8c355d5e37d to your computer and use it in GitHub Desktop.
Go 1.13 error format migration script
#!/bin/bash
FILES=$@
echo "Migrate: $FILES"
sed -i "s/errors.Wrapf(\(.*\), \"\(.*\)\", \(.*\))/fmt.Errorf(\"\2: %w\", \3, \1)/g" $FILES
sed -i "s/errors.Wrap(\(.*\), \"\(.*\)\")/fmt.Errorf(\"\2: %w\", \1)/g" $FILES
sed -i "s/errors.Errorf/fmt.Errorf/g" $FILES
goimports -w .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment