config file update

pull/261/head
Gordon 3 years ago
parent 4003befc2a
commit 22a39ed4d3

@ -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())
}
}
}

Loading…
Cancel
Save