This commit is contained in:
xing 2023-05-31 23:12:16 +08:00
parent ae6e496dd8
commit 23c9cc1596
2 changed files with 6 additions and 7 deletions

View File

@ -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") == "" {

View File

@ -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 {
err = json.Unmarshal(file, &c)
if err == nil {
break
}
return errors.New("invalid suffix config file")