Documentation
¶
Overview ¶
Package tag provides utility for parsing Go struct tags that follow a comma-separated key-value option format, similar to the `json` tag known from the standard library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tag ¶
type Tag struct {
Name string
// contains filtered or unexported fields
}
Tag represents a parsed struct tag, separating the primary name from the additional options.
func Parse ¶
Parse takes a raw tag string (e.g., `json:opt1,opt2:val`) and separates it into the primary name and the options string.
func (*Tag) Opts ¶
Opts returns an iterator sequence over the tag's options.
Each element yielded is a key-value pair. If an option does not have an explicit value (e.g., "omitempty"), the value string will be empty. Keys and values are trimmed of surrounding whitespace. Values that were quoted in the source string (e.g., `key:"value"`) will have the quotes removed. Commas inside quoted values are preserved and not treated as option separators (e.g., `key:"val1,val2"` is one option).