优化
This commit is contained in:
parent
ae6e496dd8
commit
23c9cc1596
|
@ -30,7 +30,7 @@ var address string
|
||||||
var intReg = regexp.MustCompile(`^\d`)
|
var intReg = regexp.MustCompile(`^\d`)
|
||||||
|
|
||||||
func init() {
|
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.StringVar(&address, "p", "", "listen address and port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if address == "" && os.Getenv("PORT") == "" {
|
if address == "" && os.Getenv("PORT") == "" {
|
||||||
|
|
|
@ -113,12 +113,11 @@ func InitConfig(conf string) error {
|
||||||
err = json.Unmarshal(file, &c)
|
err = json.Unmarshal(file, &c)
|
||||||
default:
|
default:
|
||||||
err = yaml.Unmarshal(file, &c)
|
err = yaml.Unmarshal(file, &c)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
err = json.Unmarshal(file, &c)
|
break
|
||||||
if err == nil {
|
}
|
||||||
break
|
err = json.Unmarshal(file, &c)
|
||||||
}
|
if err == nil {
|
||||||
} else {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return errors.New("invalid suffix config file")
|
return errors.New("invalid suffix config file")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user