@@ -54,6 +54,12 @@ You can copy/paste the following snippet into your `.pre-commit-config.yaml` fil
54
54
- id : go-vet-repo-mod
55
55
- id : go-vet-repo-pkg
56
56
#
57
+ # Revive
58
+ #
59
+ - id : go-revive
60
+ - id : go-revive-mod
61
+ - id : go-revive-repo-mod
62
+ #
57
63
# GoSec
58
64
#
59
65
- id : go-sec-mod
@@ -137,6 +143,7 @@ For file and repo-based hooks, this isn't an issue, but for module and package-b
137
143
args: [ arg1, arg2, ..., '--'] # Pass options ('--' is optional)
138
144
always_run: true # Run even if no matching files staged
139
145
alias: hook-alias # Create an alias
146
+ verbose: true # Display output, even if no errors
140
147
```
141
148
142
149
#### Passing Options To Hooks
@@ -160,6 +167,11 @@ When configured to `"always_run"`, a hook is executed as if EVERY matching file
160
167
#### Aliases
161
168
Consider adding aliases to longer-named hooks for easier CLI usage.
162
169
170
+ #### Verbose Hook Output
171
+ When the `"verbose"` flag is enabled, all output generated by the hook will be displayed, even if there were no errors.
172
+
173
+ This can be useful, for example, for hooks that display warnings, but don't generate error codes for them.
174
+
163
175
--------
164
176
## Hooks
165
177
@@ -175,6 +187,7 @@ Consider adding aliases to longer-named hooks for easier CLI usage.
175
187
- Style Checkers
176
188
- [go-lint](#go-lint)
177
189
- [go-critic](#go-critic)
190
+ - [go-revive](#go-revive)
178
191
- GolangCI-Lint
179
192
- [golangci-lint](#golangci-lint)
180
193
@@ -361,6 +374,37 @@ go get -u golang.org/x/lint/golint
361
374
- https://golang.org/doc/effective_go.html
362
375
- https://golang.org/wiki/CodeReviewComments
363
376
377
+ -------------
378
+ ### go-revive
379
+ ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint.
380
+
381
+ | Hook ID | Description
382
+ |-----------|------------
383
+ | `go-revive` | Run `'revive [$ARGS] $FILE'` for each staged .go file
384
+ | `go-revive-mod` | Run `'cd $(mod_root $FILE); revive [$ARGS] ./...'` for each staged .go file
385
+ | `go-revive-repo-mod` | Run `'cd $(mod_root); revive [$ARGS] ./...'` for each module in the repo
386
+
387
+ ##### Install
388
+ ```
389
+ go get -u github.com/mgechev/revive
390
+ ```
391
+
392
+ ##### Useful Args
393
+ ```
394
+ -config [ PATH] : Path to config file (TOML)
395
+ -exclude [ PATTERN] : Pattern for files/directories/packages to be excluded from linting
396
+ -formatter [ NAME] : formatter to be used for the output
397
+ ```
398
+
399
+ ##### Displaying Warnings
400
+ By default, `revive` doesn't generate errors on warnings, so warning messages may not be displayed if there are no accompanying error messages.
401
+
402
+ You can use the `"verbose: true"` hook configuration to always show hook output.
403
+
404
+ ##### Help
405
+ - https://github.com/mgechev/revive#usage
406
+ - `revive -h`
407
+
364
408
-------------
365
409
### go-critic
366
410
The most opinionated Go source code linter for code audit.
0 commit comments