Git has this great feature that I think is well-known but under-used. I am talking about Git hooks.
With Git hooks, you can run scripts during different Git actions.
Like this one:
This script will take a list of all the staged Go files. It will then run
gofmt to determine if these Go files are not formatted.
If you use it as a part of the pre-commit hook of your Git repository in your Go project, it will prevent commits with unformatted Go files.
To use it as the pre-commit hook, save it as
pre-commit inside the
comments powered by Disqus