config file update

This commit is contained in:
Gordon 2022-08-01 16:56:06 +08:00
parent 4003befc2a
commit 22a39ed4d3

View File

@ -512,10 +512,21 @@ type PDefaultTips struct {
func init() {
cfgName := os.Getenv("CONFIG_NAME")
fmt.Println("GET IM DEFAULT CONFIG PATH :", Root, "ENV PATH:", cfgName)
if len(cfgName) != 0 {
bytes, err := ioutil.ReadFile(filepath.Join(cfgName, "config", "config.yaml"))
if err != nil {
bytes, err = ioutil.ReadFile(filepath.Join(Root, "config", "config.yaml"))
if err != nil {
panic(err.Error())
}
} else {
Root = cfgName
}
fmt.Println("GET IM DEFAULT CONFIG PATH :", Root, "ENV PATH:", cfgName)
if err = yaml.Unmarshal(bytes, &Config); err != nil {
panic(err.Error())
}
} else {
bytes, err := ioutil.ReadFile(filepath.Join(Root, "config", "config.yaml"))
if err != nil {
panic(err.Error())
@ -523,4 +534,6 @@ func init() {
if err = yaml.Unmarshal(bytes, &Config); err != nil {
panic(err.Error())
}
}
}