go - 为什么 'go vet' 只在某些版本的 Go 中报错?

标签 go

<分区>

今天,我在构建 go 服务的管道之一中加入了“go vet”。我想知道为什么 go vet 在我本地机器上的输出与在 CI 服务器上运行的输出不同。

我发现 go 版本有所不同 - 至少有一点不同。我本地的 Go 版本是 1.12.4,CIs 是 1.12.7 版本。这个事实可以解释不同的行为,但我不明白为什么会这样!

有气味:

type Something struct {
    ...
    BatteryNumber string    `json:"number"`
    ...
}

type SomethingWithBattery struct {
    Something
    Number            string   `json:"number"`
    ...
}

因此,结构标记中的“数字”两次,因为 Something-struct 是嵌套的 SomethingWithBattery - 1.12.4 提示,1.12.7 没有。为什么?

最佳答案

Go 1 and the Future of Go Programs

Tools

Finally, the Go toolchain (compilers, linkers, build tools, and so on) is under active development and may change behavior. This means, for instance, that scripts that depend on the location and properties of the tools may be broken by a point release.


go vet 正在积极开发中,最近已被重写。没有工具的兼容性保证,只有语言。


cmd/vet: Consider reverting tag conflict for embedded fields #30465

go vet fails due to intended shadowing of embedded fields with json tags.


此外,错误修复也应用于 Go 工具。例如,Issue 30465 .

关于go - 为什么 'go vet' 只在某些版本的 Go 中报错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57428374/

相关文章:

c - 如何从 Go 函数返回 C 指针?

mongodb - 当我运行 docker compose 时,我的 golang(摄取)容器无法显示 "Error establishing Mongo session"

google-app-engine - 我如何配置我的存储库和 TravisCI 以自动部署到 GAE 标准环境?

goroutines 的执行顺序

go - 结构内的结构 slice/数组

curl - 如何在 Go 中设置空授权 header ?

go - 使用数据重定向

json - 为什么 json.Marshal 似乎生成了一个整数数组?

mongodb - Go mgo 包中的连接池

go - 如何使用汇编优化这个 8 位位置 popcount?