Skip to content

Instantly share code, notes, and snippets.

@eighty4
Last active February 7, 2023 16:49
Show Gist options
  • Save eighty4/d336e56f4485b337221c08d9792420cd to your computer and use it in GitHub Desktop.
Save eighty4/d336e56f4485b337221c08d9792420cd to your computer and use it in GitHub Desktop.
An appropriate pre-push Git hook for Golang projects
#!/bin/sh
set -e
go build .
go list -f '{{.Dir}}' -m | xargs go test
go mod tidy
git diff --exit-code
@eighty4
Copy link
Author

eighty4 commented Feb 7, 2023

cd go-module
curl https://gist.githubusercontent.com/eighty4/d336e56f4485b337221c08d9792420cd/raw/golang-git-hook.sh -o .git/hooks/pre-push
chmod +x .git/hooks/pre-push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment