Skip to content

feat(go-critic): Fallback to 'gocritic' if 'go-critic' not found#52

Open
TekWizely wants to merge 1 commit intomasterfrom
feat/gocritic-fallback
Open

feat(go-critic): Fallback to 'gocritic' if 'go-critic' not found#52
TekWizely wants to merge 1 commit intomasterfrom
feat/gocritic-fallback

Conversation

@TekWizely
Copy link
Copy Markdown
Owner

@TekWizely TekWizely commented Mar 15, 2026

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-critic be 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.

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.
Copy link
Copy Markdown

@mcdonnnj mcdonnnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants