golang hooks for http://pre-commit.com/
Add this to your .pre-commit-config.yaml
- repo: https://github.com/Drafteame/pre-commit-golang
rev: master
hooks:
- id: go-fmt
- id: go-lint
- id: go-imports
- id: golangci-lint
- id: go-unit-tests
- id: go-mod-tidy
- id: go-get-update
- id: goimports-reviser
go-fmt
- Runsgofmt
, requires golanggo-lint
- Runsgolint
, requires https://github.com/golang/lintgo-imports
- Runsgoimports
, requires golang.org/x/tools/cmd/goimportsgolangci-lint
- Rungolangci-lint run ./...
, requires golangci-lintgo-unit-tests
- Rungo test
to all project files with coveragego-mod-tidy
- Rungo mod tidy -v
, requires golanggo-get-update
- Rungo get -u -v ./...
to update all project dependencies if there are any availablegoimports-reviser
- Rungoimports-reviser -format [args] ./...
to format all golang files (requires goimports-reviser cli)revive
- Runsrevive
to inspect all staged files (requires revive)