Last active
September 19, 2022 09:48
-
-
Save Peltoche/60b8b81dfbf70164d0e2b88988003229 to your computer and use it in GitHub Desktop.
Go 1.13 error format migration script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.New(\"\(.*\)\")/fmt.Errorf(\"\1\")/g" $FILES | |
sed -i "s/errors.Errorf/fmt.Errorf/g" $FILES | |
goimports -w . |
lbcjbb
commented
Sep 19, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment