package utils import ( "fmt" "io/ioutil" "path/filepath" "gopkg.in/yaml.v2" ) // ConfigStructure config YAML representation type ConfigStructure struct { Mysql struct { User string Password string Database string Hostname string Port int } JWT struct { Secret string Expiration int64 } SMTP struct { Host string Port string User string Password string } Server string } // MysqlCredentials database credentials var config ConfigStructure // SetConfig set credentials from yaml file func SetConfig(filename string) error { path, err := filepath.Abs(filename) if err != nil { return nil } fmt.Println(path) dat, err := ioutil.ReadFile(path) if err != nil { return err } yaml.Unmarshal(dat, &config) return nil } // GetConfig get config from YAML file func GetConfig() ConfigStructure { return config }