package conf import ( "errors" "os" "gopkg.in/yaml.v2" ) type Configuration struct { ApiVersion string `json:"apiVersion" yaml:"apiVersion"` Port int `json:"port" yaml:"port"` MySQL MySQL `json:"mysql" yaml:"mysql"` Redis Redis `json:"redis" yaml:"redis"` } func NewConfiguration(file string)(*Configuration, error){ if file == "" { return nil ,errors.New("file not exist") } data, err := os.ReadFile(file) if err != nil { return nil, err } c := &Configuration{} err = yaml.Unmarshal(data, c) return c, err }