Tag|Docs

Primitive Values

Convert raw option values into common Go types

Tag maps raw option values into common Go field types. Use primitive fields for strings, booleans, numbers, and other simple values.

prop:"'database.host',required=true,retries=3"
schema.go
type PropTag struct {
	Key      string `option:"value"`
	Required bool   `option:"required"`
	Retries  int    `option:"retries"`
}

Common field types

Primitive fields keep common tag options typed without adding custom parsing:

type FieldTag struct {
	Name     string `option:"value"`
	Required bool   `option:"required"`
	Limit    int    `option:"limit"`
	Format   string `option:"format"`
}

The tag stays compact, while the parsed result becomes regular Go data.

field:"'email',required=true,limit=255,format=email"

Prefer primitive values when the option should remain easy to read directly in the struct tag.

Next, use slices and maps when a tag needs repeated values or object-like metadata.

On this page