pre-commit-golang
golang hooks for http://pre-commit.com/
Using these hooks
Add this to your .pre-commit-config.yaml
- repo: git://github.com/h4ckm03d/pre-commit-golang
rev: master
hooks:
- id: go-fmt
- id: go-vet
- id: go-lint
- id: go-imports
- id: go-cyclo
args: [-over=15]
- id: validate-toml
- id: no-go-testing
- id: gometalinter
- id: golangci-lint
- id: go-critic
- id: go-unit-tests
- id: go-build
- id: go-mod-tidy
- id: go-revive
Available hooks
go-fmt
- Runsgofmt
, requires golanggo-vet
- Runsgo vet
, requires golanggo-lint
- Runsgolint
, requires https://github.com/golang/lintgo-imports
- Runsgoimports
, requires golang.org/x/tools/cmd/goimportsgo-cyclo
- Runsgocyclo
, require https://github.com/fzipp/gocyclovalidate-toml
- Runstomlv
, requires https://github.com/BurntSushi/toml/tree/master/cmd/tomlvno-go-testing
- Checks that no files are usingtesting.T
, if you want developers to use a different testing frameworkgometalinter
- rungometalinter --config gometalinter.json ./...
golangci-lint
- rungolangci-lint run ./...
, requires golangci-lintgo-critic
- rungocritic check ./...
, requires go-criticgo-unit-tests
- rungo test -tags=unit -timeout 30s -short -v
go-build
- rungo build
, requires golanggo-mod-tidy
- rungo mod tidy -v
, requires golanggo-mod-vendor
- rungo mod vendor
, requires `golanggo-revive
- runrevive -config revive.toml -formatter friendly ./...