Skip to content

Pre-Commit

Using Pre-Commit Tooling🔗

Here's how to setup pre-commit for Go projects.

  1. Install pre-commit for macOS: brew install pre-commit or see directions for curl/other options for WSL, Windows, Linux, etc.
  2. Use the template from TekWizely/pre-commit-golang: Pre-Commit hooks for Golang with support for Modules
  3. Several options are provided for fmt oriented commands. Comment out any duplicates that don't apply.
  4. Finally initialize the pre-commit hooks in your repo by running: pre-commit install

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.