Declarative struct tag parser
Parse struct tags into typed Go values
Define a tiny schema, call `tag.Parse`, and stop hand-parsing custom tag options.
type DataSourceTag struct {
Host string `option:"value"`
Username string `option:"username"`
Password string `option:"password"`
Driver string `option:"driver"`
}
func (DataSourceTag) Tag() string { return "datasource" }import "go.codnect.io/tag"
func main() {
source := &DataSourceTag{}
err := tag.Parse(
`datasource:"'localhost:5432',username=...,password=...,driver=postgresql"`,
source,
)
}Why Tag
Tag gives Go packages a small, typed way to read and write custom struct tag formats.
Parse tags safely
Turn compact struct tag strings into predictable Go values without scattered string handling.
Format consistently
Keep generated or rewritten tags stable, readable, and easier to review across changes.
Work with tag values
Read primary values, key-value pairs, flags, slices, maps, and nested options from one parser shape.
Built for Go packages
Use it inside libraries, generators, and framework code that needs typed metadata from structs.
Latest news
Updates from Tag
Release notes, parsing examples, and project updates for Tag.
FAQ
Common questions
A few practical answers about where Tag fits and how custom tag parsing works.
Why use Tag for struct tag parsing?+
Tag keeps custom tag formats small and typed, so packages can parse compact option strings without hand-written splitting and conversion code.
Is Tag only for one tag format?+
No. You define the schema with Go structs, fields, and tag metadata, then use the same parser shape for different custom tag formats.
When does Tag help most?+
It is useful when a package accepts tag options with primary values, key-value pairs, flags, slices, maps, or nested values and needs them as typed Go data.
Discover more
Join the Codnect community
Follow the projects, share ideas, and help shape open source software for developer ecosystems