golangci-lint在重新安装后出现了未见过的错误。

huangapple go评论75阅读模式
英文:

golangci-lint gives unseen errors after reinstalling

问题

我将go的版本升级到了go1.18.3,按照https://go.dev/doc/install上的指示进行操作:

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

然后我尝试运行我的go项目的Makefile,但提示未安装golangci-lint。我猜这可能是由于rm -rf /usr/local/go导致所有的包都被删除了,或者在升级过程中我弄乱了文件。
我继续安装golangci-lint:

go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2

报告了许多以前未见过的错误,比如:

could not import math/bits (-: could not load export data: cannot import "math/bits" (unknown export format version 2), export data is newer version - update tool)

undeclared name: `yaml

...

我感到很困惑,因为在进行代码检查之前,该项目曾经成功编译过。我应该降级golangci-lint吗?

英文:

I upgraded the version of go to go1.18.3, following the instruction on https://go.dev/doc/install:

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

Then I tried to run a Makefile for my go project but was prompted that golangci-lint was not installed. I assume that this was due to rm -rf /usr/local/go and all the packages were removed, or I somehow messed up with the files during the upgrade.
I went on to install golangci-lint:

go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2

A lot of previously unseen errors were reported. Like

could not import math/bits (-: could not load export data: cannot import "math/bits" (unknown iexport format version 2), export data is newer version - update tool)'

undeclared name: `yaml

...

I'm quite confused because the project used to compile successfully after lint checks.
Should I downgrade gplangci-lint?

答案1

得分: 1

go install 将会把 golangci-lint 安装到你的 go/bin 路径中。之前它就是存在那里的,你说得对,rm -rf /usr/local/go 命令会将其删除。

至于新报告的错误,每次 golangci-lint 的更新都会引入更多的规则和检查器。你可以选择降级、修复这些错误,或者根据你的偏好配置 golangci-lint。详情请参考:https://golangci-lint.run/usage/configuration/

英文:

go install Will install golangci-lint into your go/bin path. And that is previous where it lived and you are correct that rm -rf /usr/local/go would have remove it.

As for the newly reported errors, every update of golangci-lint will bring in more rules and linters. You can either downgrade, fix the errors or configure golangci-lint to your preferences https://golangci-lint.run/usage/configuration/

huangapple
  • 本文由 发表于 2022年6月17日 16:09:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/72656235.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定