Struct tags in Golang
· One min read
A struct tag is a special type of comment on a member of a struct. These comments can be inspected by code and runtime to provide additional functionality
- https://www.digitalocean.com/community/tutorials/how-to-use-struct-tags-in-go
- https://pkg.go.dev/reflect#StructTag
- SO with list of known struct tags: https://stackoverflow.com/a/53530943
- https://github.com/golang/go/wiki/Well-known-struct-tags
Example from the DigitalOcean article, showing the example struct tag
type User struct {
Name string `example:"name"`
}