Exemple #1
0
func main() {
	config := Config{}

	err := envtag.Unmarshal(&config)
	if err != nil {
		panic(err)
	}

	fmt.Println("HOME:", config.Home)
	fmt.Println("LOCATION:", config.Location)
}
Exemple #2
0
func main() {
	data, err := ioutil.ReadFile("sample.yaml")
	if err != nil {
		panic(err)
	}

	config := Config{}

	err = yaml.Unmarshal(data, &config)
	if err != nil {
		panic(err)
	}

	err = envtag.Unmarshal(&config)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%+v\n", config)
}