go vet "struct field tag not compatible with reflect.StructTag.Get" in CI
The structtag analyzer validates struct field tags. A tag missing the key:"value" quoting, or with a stray space, is flagged because reflect.StructTag.Get would silently fail to read it.
What this error means
go vet reports "struct field tag json:name not compatible with reflect.StructTag.Get: bad syntax for struct tag value".
go vet
./model.go:6:2: struct field tag `json:name` not compatible with reflect.StructTag.Get: bad syntax for struct tag valueCommon causes
Missing quotes around the tag value
A tag like json:name lacks the required quotes; it must be json:"name" for the reflect parser to read it.
A stray space between key and value
A space after the colon (json: "name") breaks the conventional tag syntax the analyzer expects.
How to fix it
Use the key:"value" form
- Quote each tag value and remove spaces around the colon.
- Separate multiple keys with single spaces inside the backticks.
- Re-run
go vet ./....
model.go
Name string `json:"name" xml:"name"`Let gofmt and vet guard tags
Run go vet in CI so malformed tags, which otherwise fail silently at runtime, are caught at build time.
How to prevent it
- Always quote struct tag values:
key:"value". - Run
go vet ./...in CI to validate tags. - Avoid spaces inside the backtick tag literal except between keys.
Related guides
go vet "Printf arg of wrong type" in CIFix go vet "Printf format %d has arg of wrong type string" in CI - a format verb does not match the type of t…
go vet "wrong signature for TestX, must be func TestX(t *testing.T)" in CIFix go vet "wrong signature for TestX, must be func TestX(t *testing.T)" in CI - a test function has the Test…
go vet "unreachable code" in CIFix go vet "unreachable code" in CI - statements follow a terminating statement such as return, panic, or an…