Tag
Guides

Nested Structs

Bind nested tag values into custom structs

Nested Structs

Nested map-like values can be bound to custom structs.

database:"{'host':'localhost','port':5432,'credentials':{'user':'admin','password':'secret'}}"
type Credentials struct {
	User     string `option:"user"`
	Password string `option:"password"`
}

type DatabaseTag struct {
	Host        string      `option:"host"`
	Port        int         `option:"port"`
	Credentials Credentials `option:"credentials"`
}

func (t DatabaseTag) Tag() string {
	return "database"
}

On this page