This online resource will get you halfway there:
https://mengzhuo.github.io/yaml-to-go/
Pasting your yaml yields this:
type AutoGenerated struct {
API struct {
Local struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
} `yaml:"local"`
Develop struct {
Host interface{} `yaml:"host"`
Port interface{} `yaml:"port"`
} `yaml:"develop"`
Production struct {
Host interface{} `yaml:"host"`
Port interface{} `yaml:"port"`
} `yaml:"production"`
} `yaml:"api"`
RestAPI struct {
Local struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
} `yaml:"local"`
Develop struct {
Host interface{} `yaml:"host"`
Port interface{} `yaml:"port"`
} `yaml:"develop"`
Production struct {
Host interface{} `yaml:"host"`
Port interface{} `yaml:"port"`
} `yaml:"production"`
} `yaml:"rest-api"`
}
There's obvious sub-type duplicates. So it can be trimmed.
First pass:
type Address struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
}
type MyConfig struct {
API struct {
Local Address `yaml:"local"`
Develop Address `yaml:"develop"`
Production Address `yaml:"production"`
} `yaml:"api"`
RestAPI struct {
Local Address `yaml:"local"`
Develop Address `yaml:"develop"`
Production Address `yaml:"production"`
} `yaml:"rest-api"`
}
Second (and final) pass:
type Address struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
}
type Deployment struct {
Local Address `yaml:"local"`
Develop Address `yaml:"develop"`
Production Address `yaml:"production"`
}
type MyConfig struct {
API Deployment `yaml:"api"`
RestAPI Deployment `yaml:"rest-api"`
}