优化
This commit is contained in:
parent
ae6e496dd8
commit
23c9cc1596
|
@ -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") == "" {
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user