golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.83k stars 17.65k forks source link

cmd/vet: go vet incorrectly romalformed struct tags #9784

Closed davecgh closed 9 years ago

davecgh commented 9 years ago

The latest version of go vet (go 1.4.1 with latest tools repo commit golang/tools@913f41fc5f1b7afd8f7c66c011c1ad368fa23fb8) is incorrectly reporting malformed struct tags when one of the tag values contains spaces.

Here is a minimal set of steps to reproduce the issue:

$ mkdir $GOPATH/src/govetissue
$ cd $GOPATH/src/govetissue
$ cat > main.go  <<END
package main

type foo struct {
    A int \`short:"V" description:"Test description"\`
}

func main() {
}
END
$ go vet

Output:

/home/davec/mygo/src/govetissue/main.go:4: struct field tag short:"V" description:"Test description" not compatible with reflect.StructTag.Get: bad syntax for struct tag value exit status 1

Removing the space inside the quoted value for the description (i.e. TestDescription) does not report the error, but clearly that is not the intended behavior.

I've reproduced this issue with Windows, Linux, and OpenBSD.

minux commented 9 years ago

This is https://github.com/golang/go/issues/9500#issuecomment-70218780.

At least two fixes are being reviewed.