pre-commit-golang icon indicating copy to clipboard operation
pre-commit-golang copied to clipboard

Add golangci-lint v2 hooks with formatting support

Open JackismyShephard opened this issue 5 months ago • 3 comments

Adds 7 new hooks for golangci-lint v2 architecture with support for version: "2" config files. Includes both linting hooks (golangci-lint-v2*) and formatting hooks (golangci-lint-v2-fmt*) that use the built-in fmt command.

Issue: https://github.com/TekWizely/pre-commit-golang/issues/41

JackismyShephard avatar Aug 06 '25 18:08 JackismyShephard

Greetings @JackismyShephard and thank you for taking the time to create a PR for my project ...

Upon reviewing the changes and looking into it, I have some issues with:

go install github.com/golangci/golangci-lint/cmd/golangci-lint-v2@latest

This command does not actually appear to work?

And indeed there is no golangci-lint-v2 folder in the cmd folder:

  • https://github.com/golangci/golangci-lint/tree/main/cmd

Additionally, installing it via any of the local installation options does not install the binary as golangci-lint-v2 - It appears to just install as golangci-lint

Q: (assuming v2 is installed with its standard name golangci-lint) will the existing hooks still invoke the linting (run) actions correctly?

I'm going to assume yes for the moment as I haven't seen anything to suggest otherwise yet. If true, then we don't necessarily need two sets of hooks for the lint action.

Its nice to see that they've added support for formatters. However golangci-lint-fmt-repo-mod is a mouthful :)

I'm wondering if we might instead introduce the formatting option hooks as golangci-fmt (i.e. golang-fmt, golang-fmt-mod, etc) ? It doesn't match the binary name but it matches the spirit of the formatting action.

Please take a minute to read and reply and we can continue the discussion.

Thanks again!

-TW

TekWizely avatar Aug 10 '25 06:08 TekWizely

Hi, see previous comment - Looking forward to future discussion on this PR, thanks!

Sorry for not getting back to you. I am a bit busy this week. Will see if I have proper time to look at this this weekend 😊

JackismyShephard avatar Aug 11 '25 21:08 JackismyShephard

Hy @JackismyShephard just a friendly ping to see if you've made any progress on this? No worries if not - Hope all is well. -TW

TekWizely avatar Sep 02 '25 21:09 TekWizely