Introduction
Learn what Tag is and why it exists
Introduction
Tag is a lightweight Go library for parsing raw struct tag strings into strongly typed Go values.
Go's reflect.StructTag gives you tag values as strings. That is enough for
simple tags, but custom tag formats often need more: default values, boolean
flags, lists, maps, nested options, custom types, and consistent error handling.
Tag lets you define the shape of a tag with a Go struct. The parser reads the raw tag expression and fills that struct with typed values.
Why Use Tag?
Without a shared parser, custom tags usually produce repeated parsing code:
- splitting strings by commas
- detecting boolean flags
- converting strings into numbers and booleans
- handling quoted values
- mapping option names to fields
- repeating edge-case logic across packages
Tag moves that work into a reusable parser and keeps your application code close to the data it actually needs.
Good Fits
Tag is useful when building custom tag formats for:
- configuration
- validation
- metadata mapping
- code generation
- framework and library annotations
