@@ -423,12 +423,12 @@ This can be useful, for example, for hooks that display warnings, but don't gene
423
423
### go-build
424
424
Compiles packages, along with their dependencies, but does not install the results.
425
425
426
- | Hook ID | Description
427
- |---------------------|------------
428
- | `go-build-mod` | Run `'cd $(mod_root $FILE); go build -o /dev/null [$ARGS] ./...'` for each staged .go file
429
- | `go-build-pkg` | Run `'go build -o /dev/null [$ARGS] ./$(dirname $FILE)'` for each staged .go file
430
- | `go-build-repo-mod` | Run `'cd $(mod_root); go build -o /dev/null [$ARGS] ./...'` for each module in the repo
431
- | `go-build-repo-pkg` | Run `'go build -o /dev/null [$ARGS] ./...'` in repo root folder
426
+ | Hook ID | Description |
427
+ |---------------------|--------------------------------------------------------------------------------------------|
428
+ | `go-build-mod` | Run `'cd $(mod_root $FILE); go build -o /dev/null [$ARGS] ./...'` for each staged .go file |
429
+ | `go-build-pkg` | Run `'go build -o /dev/null [$ARGS] ./$(dirname $FILE)'` for each staged .go file |
430
+ | `go-build-repo-mod` | Run `'cd $(mod_root); go build -o /dev/null [$ARGS] ./...'` for each module in the repo |
431
+ | `go-build-repo-pkg` | Run `'go build -o /dev/null [$ARGS] ./...'` in repo root folder |
432
432
433
433
##### Install
434
434
Comes with Golang ( [golang.org](https://golang.org/) )
@@ -441,10 +441,10 @@ Comes with Golang ( [golang.org](https://golang.org/) )
441
441
### go-mod-tidy
442
442
Makes sure `go.mod` matches the source code in the module.
443
443
444
- | Hook ID | Description
445
- |--------------------|------------
446
- | `go-mod-tidy` | Run `'cd $(mod_root $FILE); go mod tidy [$ARGS] ./...'` for each staged .go file
447
- | `go-mod-tidy-repo` | Run `'cd $(mod_root); go mod tidy [$ARGS] ./...'` for each module in the repo
444
+ | Hook ID | Description |
445
+ |--------------------|----------------------------------------------------------------------------------|
446
+ | `go-mod-tidy` | Run `'cd $(mod_root $FILE); go mod tidy [$ARGS] ./...'` for each staged .go file |
447
+ | `go-mod-tidy-repo` | Run `'cd $(mod_root); go mod tidy [$ARGS] ./...'` for each module in the repo |
448
448
449
449
##### Install
450
450
Comes with Golang ( [golang.org](https://golang.org/) )
@@ -457,12 +457,12 @@ Comes with Golang ( [golang.org](https://golang.org/) )
457
457
### go-test
458
458
Automates testing, printing a summary of test results.
459
459
460
- | Hook ID | Description
461
- |--------------------|------------
462
- | `go-test-mod` | Run `'cd $(mod_root $FILE); go test [$ARGS] ./...'` for each staged .go file
463
- | `go-test-pkg` | Run `'go test [$ARGS] ./$(dirname $FILE)'` for each staged .go file
464
- | `go-test-repo-mod` | Run `'cd $(mod_root); go test [$ARGS] ./...'` for each module in the repo
465
- | `go-test-repo-pkg` | Run `'go test [$ARGS] ./...'` in repo root folder
460
+ | Hook ID | Description |
461
+ |--------------------|------------------------------------------------------------------------------|
462
+ | `go-test-mod` | Run `'cd $(mod_root $FILE); go test [$ARGS] ./...'` for each staged .go file |
463
+ | `go-test-pkg` | Run `'go test [$ARGS] ./$(dirname $FILE)'` for each staged .go file |
464
+ | `go-test-repo-mod` | Run `'cd $(mod_root); go test [$ARGS] ./...'` for each module in the repo |
465
+ | `go-test-repo-pkg` | Run `'go test [$ARGS] ./...'` in repo root folder |
466
466
467
467
##### Install
468
468
Comes with Golang ( [golang.org](https://golang.org/) )
@@ -475,12 +475,12 @@ Comes with Golang ( [golang.org](https://golang.org/) )
475
475
### go-sec
476
476
Inspects source code for security problems by scanning the Go AST.
477
477
478
- | Hook ID | Description
479
- |-------------------|------------
480
- | `go-sec-mod` | Run `'cd $(mod_root $FILE); gosec [$ARGS] ./...'` for each staged .go file
481
- | `go-sec-pkg` | Run `'gosec [$ARGS] ./$(dirname $FILE)'` for each staged .go file
482
- | `go-sec-repo-mod` | Run `'cd $(mod_root); gosec [$ARGS] ./...'` for each module in the repo
483
- | `go-sec-repo-pkg` | Run `'gosec [$ARGS] ./...'` in repo root folder
478
+ | Hook ID | Description |
479
+ |-------------------|----------------------------------------------------------------------------|
480
+ | `go-sec-mod` | Run `'cd $(mod_root $FILE); gosec [$ARGS] ./...'` for each staged .go file |
481
+ | `go-sec-pkg` | Run `'gosec [$ARGS] ./$(dirname $FILE)'` for each staged .go file |
482
+ | `go-sec-repo-mod` | Run `'cd $(mod_root); gosec [$ARGS] ./...'` for each module in the repo |
483
+ | `go-sec-repo-pkg` | Run `'gosec [$ARGS] ./...'` in repo root folder |
484
484
485
485
##### Install (via [bingo](https://github.com/TekWizely/bingo))
486
486
```
@@ -495,12 +495,12 @@ bingo install github.com/securego/gosec/v2/cmd/gosec
495
495
### go-staticcheck
496
496
A state of the art linter for the Go programming language. Using static analysis, it finds bugs and performance issues, offers simplifications, and enforces style rules.
497
497
498
- | Hook ID | Description
499
- |---------------------------|------------
500
- | `go-staticcheck-mod` | Run `'cd $(mod_root $FILE); staticcheck [$ARGS] ./...'` for each staged .go file
501
- | `go-staticcheck-pkg` | Run `'staticcheck [$ARGS] ./$(dirname $FILE)'` for each staged .go file
502
- | `go-staticcheck-repo-mod` | Run `'cd $(mod_root); staticcheck [$ARGS] ./...'` for each module in the repo
503
- | `go-staticcheck-repo-pkg` | Run `'staticcheck [$ARGS] ./...'` in repo root folder
498
+ | Hook ID | Description |
499
+ |---------------------------|----------------------------------------------------------------------------------|
500
+ | `go-staticcheck-mod` | Run `'cd $(mod_root $FILE); staticcheck [$ARGS] ./...'` for each staged .go file |
501
+ | `go-staticcheck-pkg` | Run `'staticcheck [$ARGS] ./$(dirname $FILE)'` for each staged .go file |
502
+ | `go-staticcheck-repo-mod` | Run `'cd $(mod_root); staticcheck [$ARGS] ./...'` for each module in the repo |
503
+ | `go-staticcheck-repo-pkg` | Run `'staticcheck [$ARGS] ./...'` in repo root folder |
504
504
505
505
##### Install (via [bingo](https://github.com/TekWizely/bingo))
506
506
```
@@ -517,12 +517,12 @@ Recommends struct field rearrangements to provide for maximum space/allocation e
517
517
518
518
- Can modify files (see `-apply`)
519
519
520
- | Hook ID | Description
521
- |--------------------------|------------
522
- | `go-structslop-mod` | Run `'cd $(mod_root $FILE); structslop [$ARGS] ./...'` for each staged .go file
523
- | `go-structslop-pkg` | Run `'structslop [$ARGS] ./$(dirname $FILE)'` for each staged .go file
524
- | `go-structslop-repo-mod` | Run `'cd $(mod_root); structslop [$ARGS] ./...'` for each module in the repo
525
- | `go-structslop-repo-pkg` | Run `'structslop [$ARGS] ./...'` in repo root folder
520
+ | Hook ID | Description |
521
+ |--------------------------|---------------------------------------------------------------------------------|
522
+ | `go-structslop-mod` | Run `'cd $(mod_root $FILE); structslop [$ARGS] ./...'` for each staged .go file |
523
+ | `go-structslop-pkg` | Run `'structslop [$ARGS] ./$(dirname $FILE)'` for each staged .go file |
524
+ | `go-structslop-repo-mod` | Run `'cd $(mod_root); structslop [$ARGS] ./...'` for each module in the repo |
525
+ | `go-structslop-repo-pkg` | Run `'structslop [$ARGS] ./...'` in repo root folder |
526
526
527
527
##### Install (via [bingo](https://github.com/TekWizely/bingo))
528
528
```
@@ -545,13 +545,13 @@ Printf calls whose arguments do not align with the format string. Vet uses
545
545
heuristics that do not guarantee all reports are genuine problems, but it
546
546
can find errors not caught by the compilers.
547
547
548
- | Hook ID | Description
549
- |-------------------|------------
550
- | `go-vet` | Run `'go vet [$ARGS] $FILE'` for each staged .go file
551
- | `go-vet-mod` | Run `'cd $(mod_root $FILE); go vet [$ARGS] ./...'` for each staged .go file
552
- | `go-vet-pkg` | Run `'go vet [$ARGS] ./$(dirname $FILE)'` for each staged .go file
553
- | `go-vet-repo-mod` | Run `'cd $(mod_root); go vet [$ARGS] ./...'` for each module in the repo
554
- | `go-vet-repo-pkg` | Run `'go vet [$ARGS] ./...'` in repo root folder
548
+ | Hook ID | Description |
549
+ |-------------------|-----------------------------------------------------------------------------|
550
+ | `go-vet` | Run `'go vet [$ARGS] $FILE'` for each staged .go file |
551
+ | `go-vet-mod` | Run `'cd $(mod_root $FILE); go vet [$ARGS] ./...'` for each staged .go file |
552
+ | `go-vet-pkg` | Run `'go vet [$ARGS] ./$(dirname $FILE)'` for each staged .go file |
553
+ | `go-vet-repo-mod` | Run `'cd $(mod_root); go vet [$ARGS] ./...'` for each module in the repo |
554
+ | `go-vet-repo-pkg` | Run `'go vet [$ARGS] ./...'` in repo root folder |
555
555
556
556
##### Install
557
557
Comes with Golang ( [golang.org](https://golang.org/) )
@@ -566,10 +566,10 @@ Formats Go programs. It uses tabs for indentation and blanks for alignment. Alig
566
566
567
567
- Can modify files (see `-w`)
568
568
569
- | Hook ID | Description
570
- |---------------|------------
571
- | `go-fmt` | Run `'gofmt -l -d [$ARGS] $FILE'` for each staged .go file
572
- | `go-fmt-repo` | Run `'gofmt -l -d [$ARGS] .'` in repo root folder
569
+ | Hook ID | Description |
570
+ |---------------|------------------------------------------------------------|
571
+ | `go-fmt` | Run `'gofmt -l -d [$ARGS] $FILE'` for each staged .go file |
572
+ | `go-fmt-repo` | Run `'gofmt -l -d [$ARGS] .'` in repo root folder |
573
573
574
574
##### Install
575
575
Comes with Golang ( [golang.org](https://golang.org/) )
@@ -592,10 +592,10 @@ Enforce a stricter format than `gofmt`, while being backwards compatible.
592
592
- Replaces `go-fmt`
593
593
- Can modify files (see `-w`)
594
594
595
- | Hook ID | Description
596
- |-----------------|------------
597
- | `go-fumpt` | Run `'gofumpt -l -d [$ARGS] $FILE'` for each staged .go file
598
- | `go-fumpt-repo` | Run `'gofumpt -l -d [$ARGS] .'` in repo root folder
595
+ | Hook ID | Description |
596
+ |-----------------|--------------------------------------------------------------|
597
+ | `go-fumpt` | Run `'gofumpt -l -d [$ARGS] $FILE'` for each staged .go file |
598
+ | `go-fumpt-repo` | Run `'gofumpt -l -d [$ARGS] .'` in repo root folder |
599
599
600
600
##### Install (via [bingo](https://github.com/TekWizely/bingo))
601
601
```
@@ -621,10 +621,10 @@ Updates your Go import lines, adding missing ones and removing unreferenced ones
621
621
- Replaces `go-fmt`
622
622
- Can modify files (see `-w`)
623
623
624
- | Hook ID | Description
625
- |-------------------|------------
626
- | `go-imports` | Run `'goimports -l -d [$ARGS] $FILE'` for each staged .go file
627
- | `go-imports-repo` | Run `'goimports -l -d [$ARGS] .'` in repo root folder
624
+ | Hook ID | Description |
625
+ |-------------------|----------------------------------------------------------------|
626
+ | `go-imports` | Run `'goimports -l -d [$ARGS] $FILE'` for each staged .go file |
627
+ | `go-imports-repo` | Run `'goimports -l -d [$ARGS] .'` in repo root folder |
628
628
629
629
##### Install (via [bingo](https://github.com/TekWizely/bingo))
630
630
```
@@ -652,10 +652,10 @@ Implements a Go pretty-printer (like `go-fmt`) that also adds zero-value return
652
652
- Replaces `go-fmt` and `go-imports`
653
653
- Can modify files (see `-w`)
654
654
655
- | Hook ID | Description
656
- |-------------------|------------
657
- | `go-returns` | Run `'goreturns -l -d [$ARGS] $FILE'` for each staged .go file
658
- | `go-returns-repo` | Run `'goreturns -l -d [$ARGS] .'` in repo root folder
655
+ | Hook ID | Description |
656
+ |-------------------|----------------------------------------------------------------|
657
+ | `go-returns` | Run `'goreturns -l -d [$ARGS] $FILE'` for each staged .go file |
658
+ | `go-returns-repo` | Run `'goreturns -l -d [$ARGS] .'` in repo root folder |
659
659
660
660
##### Install (via [bingo](https://github.com/TekWizely/bingo))
661
661
```
@@ -682,9 +682,9 @@ bingo install github.com/sqs/goreturns
682
682
### go-lint
683
683
A linter for Go source code, meant to carry out the stylistic conventions put forth in [Effective Go](https://golang.org/doc/effective_go.html) and [CodeReviewComments](https://golang.org/wiki/CodeReviewComments).
684
684
685
- | Hook ID | Description
686
- |-----------|------------
687
- | `go-lint` | Run `'golint -set_exit_status [$ARGS] $FILE'` for each staged .go file
685
+ | Hook ID | Description |
686
+ |-----------|------------------------------------------------------------------------|
687
+ | `go-lint` | Run `'golint -set_exit_status [$ARGS] $FILE'` for each staged .go file |
688
688
689
689
##### Install (via [bingo](https://github.com/TekWizely/bingo))
690
690
```
@@ -701,11 +701,11 @@ bingo install golang.org/x/lint/golint
701
701
### go-revive
702
702
\~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint.
703
703
704
- | Hook ID | Description
705
- |-----------|------------
706
- | `go-revive` | Run `'revive [$ARGS] $FILE'` for each staged .go file
707
- | `go-revive-mod` | Run `'cd $(mod_root $FILE); revive [$ARGS] ./...'` for each staged .go file
708
- | `go-revive-repo-mod` | Run `'cd $(mod_root); revive [$ARGS] ./...'` for each module in the repo
704
+ | Hook ID | Description |
705
+ |---------------------- |-----------------------------------------------------------------------------|
706
+ | `go-revive` | Run `'revive [$ARGS] $FILE'` for each staged .go file |
707
+ | `go-revive-mod` | Run `'cd $(mod_root $FILE); revive [$ARGS] ./...'` for each staged .go file |
708
+ | `go-revive-repo-mod` | Run `'cd $(mod_root); revive [$ARGS] ./...'` for each module in the repo |
709
709
710
710
##### Support for Repository-Level Config
711
711
As of time of writing, revive only auto-checks for configs in `${HOME}/revive.toml`, and doesn't check the local folder (ie. `${REPO_ROOT}/revive.toml`).
@@ -745,9 +745,9 @@ You can use the `"verbose: true"` hook configuration to always show hook output.
745
745
### go-critic
746
746
The most opinionated Go source code linter for code audit.
747
747
748
- | Hook ID | Description
749
- |-------------|------------
750
- | `go-critic` | Run `'gocritic check [$ARGS] $FILE'` for each staged .go file
748
+ | Hook ID | Description |
749
+ |-------------|---------------------------------------------------------------|
750
+ | `go-critic` | Run `'gocritic check [$ARGS] $FILE'` for each staged .go file |
751
751
752
752
##### Install
753
753
https://github.com/go-critic/go-critic#installation
@@ -780,13 +780,13 @@ A FAST linter aggregator, with colored output, fewer false-positives, and suppor
780
780
- Can report only new issues (see `--new`)
781
781
- Can modify files (see `--fix`)
782
782
783
- | Hook ID | Description
784
- |--------------------------|------------
785
- | `golangci-lint` | Run `'golangci-lint run [$ARGS] $FILE'` for each staged .go file
786
- | `golangci-lint-mod` | Run `'cd $(mod_root $FILE); golangci-lint run [$ARGS] ./...'` for each staged .go file
787
- | `golangci-lint-pkg` | Run `'golangci-lint run [$ARGS] ./$(dirname $FILE)'` for each staged .go file
788
- | `golangci-lint-repo-mod` | Run `'cd $(mod_root); golangci-lint run [$ARGS] ./...'` for each module in the repo
789
- | `golangci-lint-repo-pkg` | Run `'golangci-lint run [$ARGS] ./...'` in repo root folder
783
+ | Hook ID | Description |
784
+ |--------------------------|----------------------------------------------------------------------------------------|
785
+ | `golangci-lint` | Run `'golangci-lint run [$ARGS] $FILE'` for each staged .go file |
786
+ | `golangci-lint-mod` | Run `'cd $(mod_root $FILE); golangci-lint run [$ARGS] ./...'` for each staged .go file |
787
+ | `golangci-lint-pkg` | Run `'golangci-lint run [$ARGS] ./$(dirname $FILE)'` for each staged .go file |
788
+ | `golangci-lint-repo-mod` | Run `'cd $(mod_root); golangci-lint run [$ARGS] ./...'` for each module in the repo |
789
+ | `golangci-lint-repo-pkg` | Run `'golangci-lint run [$ARGS] ./...'` in repo root folder |
790
790
791
791
##### Install (via [bingo](https://github.com/TekWizely/bingo))
792
792
```
@@ -825,14 +825,14 @@ bingo install github.com/golangci/golangci-lint/cmd/golangci-lint
825
825
826
826
Using the `my-cmd-*` hooks, you can invoke custom go tools in various contexts.
827
827
828
- | Hook ID | Description
829
- |-------------------|------------
830
- | `my-cmd` | Run `'$ARGS[0] [$ARGS[1:]] $FILE'` for each staged .go file
831
- | `my-cmd-mod` | Run `'cd $(mod_root $FILE); GO111MODULE=on $ARGS[0] [$ARGS[1:]]'` for each staged .go file
832
- | `my-cmd-pkg` | Run `'GO111MODULE=off $ARGS[0] [$ARGS[1:]] ./$(dirname $FILE)'` for each staged .go file
833
- | `my-cmd-repo` | Run `'$ARGS[0] [$ARGS[1:]]'` in the repo root folder
834
- | `my-cmd-repo-mod` | Run `'cd $(mod_root); GO111MODULE=on $ARGS[0] [$ARGS[1:]]'` for each module in the repo
835
- | `my-cmd-repo-pkg` | Run `'GO111MODULE=off $ARGS[0] [$ARGS[1:]]` in repo root folder
828
+ | Hook ID | Description |
829
+ |-------------------|--------------------------------------------------------------------------------------------|
830
+ | `my-cmd` | Run `'$ARGS[0] [$ARGS[1:]] $FILE'` for each staged .go file |
831
+ | `my-cmd-mod` | Run `'cd $(mod_root $FILE); GO111MODULE=on $ARGS[0] [$ARGS[1:]]'` for each staged .go file |
832
+ | `my-cmd-pkg` | Run `'GO111MODULE=off $ARGS[0] [$ARGS[1:]] ./$(dirname $FILE)'` for each staged .go file |
833
+ | `my-cmd-repo` | Run `'$ARGS[0] [$ARGS[1:]]'` in the repo root folder |
834
+ | `my-cmd-repo-mod` | Run `'cd $(mod_root); GO111MODULE=on $ARGS[0] [$ARGS[1:]]'` for each module in the repo |
835
+ | `my-cmd-repo-pkg` | Run `'GO111MODULE=off $ARGS[0] [$ARGS[1:]]` in repo root folder |
836
836
837
837
#### Configuring the hooks
838
838
0 commit comments