Skip to content
Latchkey

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 value

Common 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

  1. Quote each tag value and remove spaces around the colon.
  2. Separate multiple keys with single spaces inside the backticks.
  3. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →