You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments