Struct semantics
Struct tags
A field tag is optional string metadata and participates in struct type identity. Packages can interpret tags according to their own contracts; the language does not automatically serialize or validate fields from a tag. Example output: 'name'.
Formal Syntax & Structure
go syntaxgo
type T struct { Field string `json:"field"` }Working Example
Example Snippetgo
package main
import "fmt"import "reflect"
type Item struct { Name string `json:"name"`}
func main() { f, _ := reflect.TypeOf(Item{}).FieldByName("Name") fmt.Println(f.Tag.Get("json"))}