Skip to content

Instantly share code, notes, and snippets.

@RollMan
Last active September 1, 2020 09:12
Show Gist options
  • Select an option

  • Save RollMan/8d44f007e5d3248093e8c7fdfea79501 to your computer and use it in GitHub Desktop.

Select an option

Save RollMan/8d44f007e5d3248093e8c7fdfea79501 to your computer and use it in GitHub Desktop.
golang_autoformat_git_commit.sh
#!/bin/sh
# https://yoshinorin.net/2018/01/07/git-pre-commit-code-format/
for FILE in `git diff --staged --name-only --diff-filter=ACMRTUB | grep '.go$'`; do
gofmt -w $FILE
git add $FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment