Go 1.18 と Generics と Linter
予測して然るべきであったが Go 1.18 に組み込まれた Generics と既存の linter の間でトラブルが続出しているらしい。
私も大変お世話になっている Go の代表的な総合 linter である golangci-lint は v1.45 で暫定的な対応を行ったようだ。
So I added a new configuration option inside the run section.
We will not have to remove this option in the future because we will be able to use it for some linters that have a Go version option.An example:
run: go: 1.18
By default, the supported Go version will be go1.17 because it allows us to run all our tests without a huge rewrite.
If you set the version to go1.18, the following linters will be inactive:
bodyclose
contextcheck
gosimple
nilerr
noctx
rowserrcheck
sqlclosecheck
staticcheck
stylecheck
tparallel
unparam
unused
wastedassign
この説明にあるように .golangci.yaml
ファイルに
run:
go: 1.18
の記述を入れることで Go 1.18 に対応していない linter を無効にしてくれるようだ。 あとは各 lint パッケージが 1.18 に対応してくれることを気長に待つしかないか。
なお Generics の機能を使わないのなら今回の件は気にしなくてよい(笑)
あと golangci-lint-action もいつの間にか v3 に上がってるな。 見落としてたかなぁ。 この辺はおいおい検証しよう。
参考図書
- プログラミング言語Go
- アラン・ドノバン (著), ブライアン・カーニハン (著), 柴田芳樹 (著)
- 丸善出版 2016-06-20 (Release 2021-07-13)
- Kindle版
- B099928SJD (ASIN)
- 評価
Kindle 版出た! 一部内容が古びてしまったが,この本は Go 言語の教科書と言ってもいいだろう。感想はこちら。