Skip to content

Instantly share code, notes, and snippets.

@thehowl
Created September 27, 2015 08:46
Show Gist options
  • Save thehowl/01129664a0f61e73b58c to your computer and use it in GitHub Desktop.
Save thehowl/01129664a0f61e73b58c to your computer and use it in GitHub Desktop.
pre-commit hook to automatically `go fmt` your changed go files
#!/bin/sh
git diff --name-only --cached | grep \.go | while read line
do
echo "hook : go fmt for $line..."
go fmt $line
git add $line
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment