You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> What steps will reproduce the problem?
Given there are 2 go source files.
// source in ./foo/foo.go
package foo
type Elem struct {
Name string
}
type Elems []Elem
// source in ./main.go
package main
import "./foo"
import "fmt"
func main() {
fmt.Println(foo.Elems{
foo.Elem{Name: "name"},
})
}
# run go tool vet in command line
$ go tool vet main.go
main.go:7:17: ./foo.Elems struct literal uses untagged fields
> What is the expected output?
No vet error.
> What do you see instead?
Vet reports error as described above.
> Which compiler are you using (5g, 6g, 8g, gccgo)?
n/a
> Which operating system are you using?
$ uname -a
Darwin Huans-MacBook-Pro.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52
PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64
> Which version are you using? (run 'go version')
go 1.0.3
> Please provide any additional information below.
If I rewrite main.go as following, go tool vet will stop complaining.
func main() {
fmt.Println(foo.Elems([]foo.Elem{ // explicitly write []foo.Elem here
foo.Elem{Name: "name"},
}))
}
The text was updated successfully, but these errors were encountered:
I don't see this happening before Go 1.1. cmd/vet does not today require resolving
imports and such in order to find out that foo.Elems is a slice, and it's unclear that
it should. We can revisit after Go 1.1.
The text was updated successfully, but these errors were encountered: