beego编译好的exe通过全路径调用会crash,看了半天,发现是解析不到配置文件,研究了下
发现beego自定义配置文件以后,需要手工parse,我表示,以为是自动化的,没想到是半自动化的……
追加,static path,view path都要这么干……
package beegoExt import ( "github.com/astaxie/beego" "os" "os/exec" "path/filepath" ) func MakeAbsolutePathSupport(){ path, _ := exec.LookPath(os.Args[0]) fileFullPath, _ := filepath.Abs(path) relativePath := filepath.Dir(fileFullPath) staticPath := relativePath+"/static" beego.SetStaticPath("/static",staticPath) viewsPath := relativePath+"/views" beego.SetViewsPath(viewsPath) beego.AppConfigPath = relativePath+"/conf/app.conf" beego.ParseConfig() }