Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: silence struct tag warning for slice types #4684

huandu opened this issue Jan 22, 2013 · 2 comments


None yet
4 participants
Copy link

commented Jan 22, 2013

> 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() {
        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)?

> 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"},

This comment has been minimized.

Copy link

commented Jan 29, 2013

Comment 1:

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.

Labels changed: added priority-later, removed priority-triage, go1.1.

Status changed to LongTerm.


This comment has been minimized.

Copy link

commented Feb 24, 2013

Comment 2:

This issue was closed by revision 83e22f1.

Status changed to Fixed.

@huandu huandu added fixed labels Feb 24, 2013

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.