Created
March 9, 2020 19:44
-
-
Save tywkeene/0f56952d4ec8e21b1771e75658ff8ec8 to your computer and use it in GitHub Desktop.
Replace snake case in golang with go lint
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 | |
for file in $(find . -name "*.go" -type f); do | |
line=$(golint -set_exit_status ${file} 2>&1 | grep underscore | grep -Eo "[a-zA-Z_]+ should be.*" ) | uniq | |
old=$(echo $line | cut -d " " -f 1) | |
new=$(echo $line | cut -d " " -f 4) | |
echo "$old -> $new" | |
sed -e "s/${old}/${new}/g" $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment