DEPRECATED: This project has been moved to
github.com/quartercastle/structtag
The motivation behind this package is that the StructTag
implementation shipped with Go's standard library is very limited in
detecting a malformed StructTag and each time StructTag.Get(key)
gets called,
it results in the StructTag
being parsed again. Another problem is that the
StructTag
can not be easily manipulated because it is basically a string.
This package provides a way to parse the StructTag
into a Tag
map. This
allows fast lookups and easy manipulation of the key value pairs within the
Tag
.
// Example of struct using tags to append metadata to fields.
type Server struct {
Host string `json:"host" env:"SERVER_HOST" default:"localhost"`
Port int `json:"port" env:"SERVER_PORT" default:"3000"`
}
go get github.com/quartercastle/tag
t, err := tag.Parse(`json:"host" env:"SERVER_HOST"`)
if err != nil {
panic(err)
}
fmt.Println(t["json"])
See godoc for full documentation.
This project is licensed under the MIT License.