Tag|Docs

Combined Options

Combine values, flags, lists, maps, and typed fields

A tag can combine the syntax pieces from the previous guides. Use this when an API needs a compact tag format with typed output.

service:"'my-service',optional,replicas=3,labels={'env':'prod','tier':'backend'},ports=[80,443]"
schema.go
type ServiceTag struct {
	Name     string            `option:"value"`
	Optional bool              `option:"optional"`
	Replicas int               `option:"replicas"`
	Labels   map[string]string `option:"labels"`
	Ports    []int             `option:"ports"`
}

func (t ServiceTag) Tag() string {
	return "service"
}

Keep combined tags readable

Combined tags should still be easy to scan. A good format usually has:

  • one clear primary value
  • boolean flags for small behavior switches
  • named options for values that need labels
  • slices or maps only when a flat option is not enough

If a tag becomes hard to read, split grouped data into nested structs or move the configuration into regular Go code.

At this point, the full guide flow is covered: start with the raw tag shape, map the primary value, add options and flags, then introduce typed and nested values only when the tag format needs them.