diff --git a/README.md b/README.md index e8c915a6c..1871acda8 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,6 @@ This application still in experiment, any change could happen, but it doesn't af ### v0.2.* -- Add feature auto-catch if run under GOPATH/bin. - ### Future - Command `check` add feature to update or generate gopack.json. diff --git a/conf/gpm.toml b/conf/gpm.toml index 84584dc5d..5555f5cc3 100644 --- a/conf/gpm.toml +++ b/conf/gpm.toml @@ -1,7 +1,7 @@ # This is a configuration file for gpm with toml format. title = "gpm(Go Package Manager)" -version = "v0.2.0 Build 0524" +version = "v0.2.1 Build 0524" user_language = "en-US" #user_language = "zh-CN" auto_backup = true diff --git a/gpm.go b/gpm.go index 69bf36a08..9bbdbd3ab 100644 --- a/gpm.go +++ b/gpm.go @@ -114,16 +114,25 @@ func getAppPath() bool { // Look up executable in PATH variable. appPath, _ = exec.LookPath(path.Base(os.Args[0])) // Check if run under $GOPATH/bin + if !utils.IsExist(appPath + "conf/") { + paths := utils.GetGOPATH() + for _, p := range paths { + if utils.IsExist(p + "/src/github.com/GPMGo/gpm/") { + appPath = p + "/src/github.com/GPMGo/gpm/" + break + } + } + } if len(appPath) == 0 { fmt.Printf("ERROR: getAppPath -> Unable to indicate current execute path.\n") return false } - appPath += "/" + appPath = filepath.Dir(appPath) + "/" if runtime.GOOS == "windows" { // Replace all '\' to '/'. - appPath = strings.Replace(filepath.Dir(appPath), "\\", "/", -1) + appPath = strings.Replace(appPath, "\\", "/", -1) } doc.SetAppConfig(appPath, config.AutoBackup)