dssj88098 2019-08-09 10:41
浏览 305
已采纳

为什么“ 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 {
    Something
    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 2019-08-09 10:54
    关注

    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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?