Commit e64847c
committed
📌 Pin
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 #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.viper module to v1.12.0 in go.mod
1 parent 3f6f904 commit e64847c
2 files changed
+12
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
345 | 347 | | |
346 | 348 | | |
347 | 349 | | |
| 350 | + | |
| 351 | + | |
348 | 352 | | |
349 | 353 | | |
350 | 354 | | |
| |||
0 commit comments