Closed
Description
Please answer these questions before submitting your issue. Thanks!
- What version of Go are you using (
go version
)?
go version go1.6.2 darwin/amd64
- What operating system and processor architecture are you using (
go env
)?
As above, darwin + amd64. Running OSX 10.11.4 - What did you do?
Rango vet
for the following code:
https://github.com/prashantv/vetrepro
Basically has a foo.go
with:
package vetrepro
type Container struct {
List StringList
}
// StringList is a list of strings
type StringList []string
And a foo_test.go
:
package vetrepro_test
import "github.com/prashantv/vetrepro"
// This causes a failure
var _ = &vetrepro.Container{
List: vetrepro.StringList{"hello", "world", "asdasd", "asdasd"},
}
// This works even though it's essentially the same.
var list = vetrepro.StringList{"hello", "world", "asdasd", "asdasd"}
var _ = &vetrepro.Container{
List: list,
}
- What did you expect to see?
No errors fromgo vet
for both places were I createvetrepro.StringList
. - What did you see instead?
An error for the first case (where theStringList
is created inline when setting theList
field), but no error for the second case, where theStringList
is created separately from theContainer
.
$ go vet .
foo_test.go:7: vetrepro.StringList composite literal uses unkeyed fields
If the issue is that vet
needs the installed packages, I'd expect that both cases would be affected.
go install
does fix this issue, but I'm not clear why the error is inconsistent between the 2 cases.