From 693de8f29356781bbeb8d034f99e892260fd311a Mon Sep 17 00:00:00 2001 From: lifeilin01 Date: Sun, 14 Jun 2020 14:59:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=9E=E7=8E=B0Modules=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/command.go | 4 ++-- conf/enumerate.go | 29 +++++++++++++++-------------- go.mod | 2 +- main.go | 1 - 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/commands/command.go b/commands/command.go index e9edaa05..91db3f0b 100644 --- a/commands/command.go +++ b/commands/command.go @@ -286,7 +286,7 @@ func ResolveCommand(args []string) { if err := flagSet.Parse(args); err != nil { log.Fatal("解析命令失败 ->", err) } - + fmt.Println(conf.WorkingDirectory) if conf.WorkingDirectory == "" { if p, err := filepath.Abs(os.Args[0]); err == nil { conf.WorkingDirectory = filepath.Dir(p) @@ -519,7 +519,7 @@ func init() { conf.ConfigurationFile = configPath } if err := gocaptcha.ReadFonts(conf.WorkingDir("static", "fonts"), ".ttf"); err != nil { - log.Fatal("读取字体文件失败 ->", err) + beego.Error("读取字体文件失败 ->", err) } gob.Register(models.Member{}) diff --git a/conf/enumerate.go b/conf/enumerate.go index a31eb3e6..746b003f 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -2,13 +2,14 @@ package conf import ( + "os/exec" "strings" - "github.com/astaxie/beego" - "strconv" - "path/filepath" - "os" "fmt" + "github.com/astaxie/beego" + "os" + "path/filepath" + "strconv" ) // 登录用户的Session名 @@ -158,7 +159,7 @@ func GetExportProcessNum() int { if exportProcessNum <= 0 || exportProcessNum > 4 { exportProcessNum = 1 } - return exportProcessNum; + return exportProcessNum } //导出项目队列的并发数量 @@ -168,7 +169,7 @@ func GetExportLimitNum() int { if exportLimitNum < 0 { exportLimitNum = 1 } - return exportLimitNum; + return exportLimitNum } //等待导出队列的长度 @@ -210,7 +211,7 @@ func IsAllowUploadFileExt(ext string) bool { //重写生成URL的方法,加上完整的域名 func URLFor(endpoint string, values ...interface{}) string { baseUrl := beego.AppConfig.DefaultString("baseurl", "") - pathUrl := beego.URLFor(endpoint, values ...) + pathUrl := beego.URLFor(endpoint, values...) if baseUrl == "" { baseUrl = BaseUrl @@ -224,12 +225,12 @@ func URLFor(endpoint string, values ...interface{}) string { if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") { return baseUrl + "/" + pathUrl } - return baseUrl + beego.URLFor(endpoint, values ...) + return baseUrl + beego.URLFor(endpoint, values...) } -func URLForNotHost(endpoint string,values ...interface{}) string { +func URLForNotHost(endpoint string, values ...interface{}) string { baseUrl := beego.AppConfig.DefaultString("baseurl", "") - pathUrl := beego.URLFor(endpoint, values ...) + pathUrl := beego.URLFor(endpoint, values...) if baseUrl == "" { baseUrl = "/" @@ -243,7 +244,7 @@ func URLForNotHost(endpoint string,values ...interface{}) string { if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") { return baseUrl + "/" + pathUrl } - return baseUrl + beego.URLFor(endpoint, values ...) + return baseUrl + beego.URLFor(endpoint, values...) } func URLForWithCdnImage(p string) string { @@ -344,12 +345,12 @@ func WorkingDir(elem ...string) string { } func init() { + if p, err := exec.LookPath(os.Args[0]); err == nil { + WorkingDirectory = p + } if p, err := filepath.Abs("./conf/app.conf"); err == nil { ConfigurationFile = p } - if p, err := filepath.Abs("./"); err == nil { - WorkingDirectory = p - } if p, err := filepath.Abs("./runtime/logs"); err == nil { LogFile = p } diff --git a/go.mod b/go.mod index 66f9fe77..248f7c32 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/howeyc/fsnotify v0.9.0 github.com/kardianos/service v1.1.0 github.com/lifei6671/gocaptcha v0.1.1 - github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect + github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/russross/blackfriday v1.5.2 github.com/russross/blackfriday/v2 v2.0.1 diff --git a/main.go b/main.go index 9160e648..b9dfe6d1 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,6 @@ import ( ) func main() { - if len(os.Args) >= 3 && os.Args[1] == "service" { if os.Args[2] == "install" { daemon.Install()