package config import ( "fmt" "github.com/spf13/viper" ) type Conf struct { ISOUser string ISOPassword string } func Config() *Conf { viper.SetConfigName("energyd") viper.SetConfigType("yaml") viper.AddConfigPath(".") err := viper.ReadInConfig() // Find and read the config file if err != nil { // Handle errors reading the config file panic(fmt.Errorf("fatal error config file: %w", err)) } return &Conf{ ISOUser: viper.Get("iso.user").(string), ISOPassword: viper.Get("iso.password").(string), } }