Go struct tag parser

Parse struct tags into typed Go values

Define a tiny schema, call `tag.Parse`, and stop hand-parsing custom tag options.

tag.go
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" }
main.go
import "codnect.io/tag"

func main() {
    source := &DataSourceTag{}
    err := tag.Parse(
        `datasource:"'localhost:5432',username=...,password=...,driver=postgresql"`,
        source,
    )
}

Copyright © 2026 Codnect.

All rights reserved.