We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1:newOptions函数里边
_, err := os.Open(opt.ConfPath) if err != nil { //文件不存在 panic(fmt.Sprintf("config path error %v", err)) } _, err = os.Open(opt.LogDir) if err != nil { //文件不存在 err := os.Mkdir(opt.LogDir, os.ModePerm) // if err != nil { fmt.Println(err) } }
_, err = os.Open(opt.BIDir) if err != nil { //文件不存在 err := os.Mkdir(opt.BIDir, os.ModePerm) // if err != nil { fmt.Println(err) } }
是不是改成下边这段代码更合适 if _, err := os.Stat(opt.ConfPath); os.IsNotExist(err) { panic(fmt.Sprintf("config path error %v", err)) } if _,err := os.Stat(opt.LogDir);os.IsNotExist(err){ if err := os.Mkdir(opt.LogDir, os.ModePerm);err != nil{ fmt.Println(err) } } if _,err := os.Stat(opt.BIDir);os.IsNotExist(err){ if err := os.Mkdir(opt.BIDir, os.ModePerm);err != nil{ fmt.Println(err) } }
2:Run 里边 f, err := os.Open(app.opts.ConfPath) if err != nil { //文件不存在 panic(fmt.Sprintf("config path error %v", err)) } 这一步检测 个人觉得可以去掉,Run之前 newOptions()里边已经检测过ConfigPath,直接去掉 然后 conf.LoadConfig(app.opts.ConfPath)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1:newOptions函数里边
_, err := os.Open(opt.ConfPath)
if err != nil {
//文件不存在
panic(fmt.Sprintf("config path error %v", err))
}
_, err = os.Open(opt.LogDir)
if err != nil {
//文件不存在
err := os.Mkdir(opt.LogDir, os.ModePerm) //
if err != nil {
fmt.Println(err)
}
}
是不是改成下边这段代码更合适
if _, err := os.Stat(opt.ConfPath); os.IsNotExist(err) {
panic(fmt.Sprintf("config path error %v", err))
}
if _,err := os.Stat(opt.LogDir);os.IsNotExist(err){
if err := os.Mkdir(opt.LogDir, os.ModePerm);err != nil{
fmt.Println(err)
}
}
if _,err := os.Stat(opt.BIDir);os.IsNotExist(err){
if err := os.Mkdir(opt.BIDir, os.ModePerm);err != nil{
fmt.Println(err)
}
}
2:Run 里边
f, err := os.Open(app.opts.ConfPath)
if err != nil {
//文件不存在
panic(fmt.Sprintf("config path error %v", err))
}
这一步检测 个人觉得可以去掉,Run之前 newOptions()里边已经检测过ConfigPath,直接去掉 然后
conf.LoadConfig(app.opts.ConfPath)
The text was updated successfully, but these errors were encountered: