2019-08-09 10:41 阅读 147

为什么“ go vet”仅在某些版本的Go中抱怨? [关闭]

Today I included 'go vet' in one of my pipelines that builds a go service. I wonder why go vet's output on my local machine is different from the one that runs on the CI server.

I figured out that the go version differs - at least a bit. My local Go version is 1.12.4 and the CIs is version 1.12.7. This fact would explain the different behaviour, but I don't get why this happens!

There is the smell:

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

type SomethingWithBattery struct {
    Number            string   `json:"number"`

So, two times 'number' in the struct tags, because Something-struct is nested SomethingWithBattery - 1.12.4 complains, 1.12.7 does not. Why?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doujian7132 doujian7132 2019-08-09 10:54

    Go 1 and the Future of Go Programs


    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 is under active development and recently it has been rewritten. There is no compatibility guarantee for tools, only the language.

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

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

    Also, bug fixes are applied to the Go tools. For example, Issue 30465.

    点赞 评论 复制链接分享