diff --git a/cmd/bin.go b/cmd/bin.go index fe2cfa5fc..9bee3d772 100644 --- a/cmd/bin.go +++ b/cmd/bin.go @@ -49,13 +49,6 @@ func runBin(ctx *cli.Context) { log.Fatal("", "No package specified") } - hd, err := com.HomeDir() - if err != nil { - log.Error("Bin", "Fail to get current user") - log.Fatal("", err.Error()) - } - - doc.HomeDir = strings.Replace(doc.RawHomeDir, "~", hd, -1) doc.LoadPkgNameList(doc.HomeDir + "/data/pkgname.list") installRepoPath = doc.HomeDir + "/repos" @@ -80,6 +73,7 @@ func runBin(ctx *cli.Context) { info := ctx.Args()[0] pkgName := info ver := "" + var err error if i := strings.Index(info, "@"); i > -1 { pkgName = info[:i] _, ver, err = validPath(info[i+1:]) diff --git a/cmd/build.go b/cmd/build.go index 9c366424a..bdb763238 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -15,7 +15,7 @@ package cmd import ( - "os" + //"os" "github.com/codegangsta/cli" @@ -47,8 +47,5 @@ func runBuild(ctx *cli.Context) { log.Fatal("", err.Error()) } - // I don't know why, but there is a folder named "~". - os.RemoveAll("~") - log.Success("SUCC", "Build", "Command execute successfully!") } diff --git a/cmd/get.go b/cmd/get.go index 39f37c6dc..0f3db4a80 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -62,13 +62,6 @@ func init() { } func runGet(ctx *cli.Context) { - hd, err := com.HomeDir() - if err != nil { - log.Error("Get", "Fail to get current user") - log.Fatal("", err.Error()) - } - - doc.HomeDir = strings.Replace(doc.RawHomeDir, "~", hd, -1) doc.LoadPkgNameList(doc.HomeDir + "/data/pkgname.list") if ctx.Bool("gopath") { diff --git a/doc/conf.go b/doc/conf.go index a20e00f28..fbc6dc783 100644 --- a/doc/conf.go +++ b/doc/conf.go @@ -35,6 +35,16 @@ var ( LocalNodes *goconfig.ConfigFile ) +func init() { + hd, err := com.HomeDir() + if err != nil { + log.Error("", "Fail to get current user") + log.Fatal("", err.Error()) + } + + HomeDir = strings.Replace(RawHomeDir, "~", hd, -1) +} + func NewGopmfile(dirPath string) *goconfig.ConfigFile { gf, err := goconfig.LoadConfigFile(dirPath + "/" + GopmFileName) if err != nil {