Using Pre-Commit Tooling🔗
Here's how to setup pre-commit for Go projects.
- Install pre-commit for macOS:
brew install pre-commitor see directions for curl/other options for WSL, Windows, Linux, etc.
- Use the template from TekWizely/pre-commit-golang: Pre-Commit hooks for Golang with support for Modules
- Several options are provided for
fmtoriented commands. Comment out any duplicates that don't apply.
- Finally initialize the pre-commit hooks in your repo by running:
Validate everything is working by running:
pre-commit run --all-files
Periodically, you can run
pre-commit autoupdate to ensure the latest version of the pre-commit hooks are upgraded.