Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tywkeene
Created March 9, 2020 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tywkeene/0f56952d4ec8e21b1771e75658ff8ec8 to your computer and use it in GitHub Desktop.
Save tywkeene/0f56952d4ec8e21b1771e75658ff8ec8 to your computer and use it in GitHub Desktop.
Replace snake case in golang with go lint
#!/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