Git pre-commit Golang hook
$ touch $GOPATH/src/example.com/myproject/.git/hooks/pre-commit
$ chmod a+x $GOPATH/src/example.com/myproject/.git/hooks/pre-commit
$ cat << 'EOF' > $GOPATH/src/example.com/myproject/.git/hooks/pre-commit
#!/bin/sh
go fmt ./...
go vet ./...
go test -cover ./...
find -type f -name '*.go' -exec wc -l {} +
find -type f -name '*.go' -exec sed '/^\s*$/d' {} + | wc -l; echo ' ↳ total (non-blank) lines of code'
EOF
#golang #git