struct tag

A string in backquotes after a struct field, such as `json:"status"`, that tells encoders like encoding/json how to name or treat that field.

In more detail

Tags keep Go field names idiomatic while the JSON keys stay lowercase and stable. The omitempty option leaves a field out when it holds its zero value. Treat tag names in a published report as part of an API: renaming one breaks consumers.

Example

Status string `json:"status"`

Related terms

Taught in

References