Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- #5547

Closed
wants to merge 54 commits into from
Closed

- #5547

wants to merge 54 commits into from

Conversation

busser
Copy link

@busser busser commented Mar 14, 2025

No description provided.

ldez added 30 commits February 17, 2025 13:21
ldez and others added 24 commits March 11, 2025 20:56
I've been trying to get `golangci-lint` to work with `go tool`. The only
issue I've run into so far is related to dependency versions.

I'm importing the `golangci-lint` module into a module that also imports
`viper`. However, while `golangci-lint` imports `v1.12.0`, my module
imports `v1.19.0` (the latest version). When I run `go tool golangci-lint`
the Go compiler compiles `golangci-lint` with `[email protected]`, which
breaks part of the `revive` linter (see issue golangci#3280). It possibly breaks
parts of other linters, but my specific configuration did not reveal it.

I'm currently working around this by removing the configuration that
`golangci-lint` can't handle when using `[email protected]`. However I
believe we can get the Go compiler to use `[email protected]` for
`golangci-lint` and whatever other version for any module that would
import `golangci-lint`. The trick is to add a replacement to
`golangci-lint`'s `go.mod`:

```gomod
replace github.com/spf13/viper => github.com/spf13/viper v1.12.0
```

I've experimented with this fix by using Go workspaces and it seems to
work as desired. The parent module can still use `[email protected]` and
the issue in the `revive` linter does not occur.

This change requires disabling the `gomoddirectives` linter in a couple
of `golangci-lint`'s tests. Those tests are completely unrelated to that
specific linter or to `go.mod`, so I figure it's fine.
Copy link

boring-cyborg bot commented Mar 14, 2025

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link

CLAassistant commented Mar 14, 2025

CLA assistant check
All committers have signed the CLA.

@busser busser closed this Mar 14, 2025
@ldez ldez changed the title arthur/go mod pin viper version - Mar 14, 2025
@ldez ldez added the declined label Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants