diff --git a/app/cmd/main.go b/app/cmd/main.go index 57ae5ef..eb18a4b 100644 --- a/app/cmd/main.go +++ b/app/cmd/main.go @@ -30,7 +30,7 @@ var address string var intReg = regexp.MustCompile(`^\d`) func init() { - flag.StringVar(&confPath, "c", "config.yaml", "config file") + flag.StringVar(&confPath, "c", "config.yaml", "config file support json,yaml or url") flag.StringVar(&address, "p", "", "listen address and port") flag.Parse() if address == "" && os.Getenv("PORT") == "" { diff --git a/app/pkg/config/config.go b/app/pkg/config/config.go index 7979d9a..c4fd23d 100644 --- a/app/pkg/config/config.go +++ b/app/pkg/config/config.go @@ -113,12 +113,11 @@ func InitConfig(conf string) error { err = json.Unmarshal(file, &c) default: err = yaml.Unmarshal(file, &c) - if err != nil { - err = json.Unmarshal(file, &c) - if err == nil { - break - } - } else { + if err == nil { + break + } + err = json.Unmarshal(file, &c) + if err == nil { break } return errors.New("invalid suffix config file")