jsontag controls how a protobuf field appears in JSON serialization.

Patterns

// Normal — appears as "code" in JSON
[(gogoproto.jsontag) = "code"]
 
// Hidden — excluded from JSON entirely
[(gogoproto.jsontag) = "-"]
 
// Optional — omit if zero value
[(gogoproto.jsontag) = "limit,omitempty"]

When to use -

For fields that come from auth context rather than the request body (e.g. entity_code populated from JWT headers server-side). Hiding it prevents it from appearing in API responses or being expected in request payloads.

See also

  • field-numbers — wire format encoding and field number rules
  • swagger — how .proto becomes external API docs