feat(go-critic): Fallback to 'gocritic' if 'go-critic' not found#52
Open
feat(go-critic): Fallback to 'gocritic' if 'go-critic' not found#52
Conversation
Not all install-sources (brew, etc) have migrated to the new name (go-critic), so we provide a transparent fall-back to gocritic when it's the only version present. If neither are present, we still use go-critic, so that it is used in the error reporting when verify_hook_cmd fails.
mcdonnnj
approved these changes
Mar 16, 2026
There was a problem hiding this comment.
Tested this locally and it looks good:
$ command -v go-critic
$ command -v gocritic
/home/linuxbrew/.linuxbrew/bin/gocritic
$ pre-commit try-repo ../../TekWizely/pre-commit-golang/ go-critic --verbose --all-files
===============================================================================
Using config:
===============================================================================
repos:
- repo: ../../TekWizely/pre-commit-golang
rev: 05f55c29a0c5cc7def5fdb4a3932b76141d58506
hooks:
- id: go-critic
===============================================================================
[INFO] Initializing environment for ../../TekWizely/pre-commit-golang.
go-critic................................................................Passed
- hook id: go-critic
- duration: 20.84s| cmd=(go-critic check) | ||
|
|
||
| # Default to newer name | ||
| # If not found, but old name found, us it |
There was a problem hiding this comment.
Just a minor typo I noticed while reviewing.
Suggested change
| # If not found, but old name found, us it | |
| # If not found, but old name found, use it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not all install-sources (brew, etc) have migrated to the new name (go-critic), so we provide a transparent fall-back to gocritic when it's the only version present.
If neither are present, we still use go-critic, so that it is used in the error reporting when verify_hook_cmd fails.
Replaces #50
cc: @mcdonnnj - I wanted the checks to go in the other direction (prefer new, settle on old) and to have
go-criticbe in the error message if neither present.Additionally, I've created go-critic/go-critic#1525 on the go-critic project asking them to address the issue.