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