Monthly Archives: September 2012

Making sure go source passes gofmt before committing

Here is a nice little snippet to make sure your go code passes gofmt before committing. Put this in .git/hooks/pre-commit: #!/bin/sh set -e d=`mktemp -d –tmpdir gofmtcheck-XXXXXX` git checkout-index –prefix “$d/” -a ret=`find . -regex ‘.*\.go$’ -exec gofmt -d ‘{}’ … Continue reading

Posted in Uncategorized | 1 Comment