From 8be1e9f865bdbf559893b357de75ef863565b1b6 Mon Sep 17 00:00:00 2001 From: yisier <1340976576@qq.com> Date: Mon, 31 Oct 2022 10:40:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/nps/nps.go | 11 ++--------- lib/common/run.go | 8 ++++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/nps/nps.go b/cmd/nps/nps.go index db6df9e..5b1c5b4 100644 --- a/cmd/nps/nps.go +++ b/cmd/nps/nps.go @@ -40,15 +40,8 @@ func main() { common.PrintVersion() return } - - if len(os.Args) <= 1 { - if err := beego.LoadAppConfig("ini", filepath.Join("./", "conf", "nps.conf")); err != nil { - log.Fatalln("load config file error", err.Error()) - } - } else { - if err := beego.LoadAppConfig("ini", filepath.Join(common.GetRunPath(), "conf", "nps.conf")); err != nil { - log.Fatalln("load config file error", err.Error()) - } + if err := beego.LoadAppConfig("ini", filepath.Join(common.GetRunPath(), "conf", "nps.conf")); err != nil { + log.Fatalln("load config file error", err.Error()) } common.InitPProfFromFile() diff --git a/lib/common/run.go b/lib/common/run.go index 6e4eb11..6370071 100644 --- a/lib/common/run.go +++ b/lib/common/run.go @@ -11,8 +11,12 @@ import ( //windows system, select the C:\Program Files\nps as config directory if exist, or select ./ func GetRunPath() string { var path string - if path = GetInstallPath(); !FileExists(path) { - return GetAppPath() + if len(os.Args) <= 1 { + return "./" + } else { + if path = GetInstallPath(); !FileExists(path) { + return GetAppPath() + } } return path }