Browse Source

Huge imporve download repos on google code

pull/103/head
Unknown 12 years ago
parent
commit
3411245256
  1. 39
      gopm.go

39
gopm.go

@ -19,9 +19,6 @@ import (
"fmt"
"io"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
"sync"
@ -29,8 +26,8 @@ import (
"unicode"
"unicode/utf8"
"github.com/Unknwon/com"
"github.com/gpmgo/gopm/cmd"
"github.com/gpmgo/gopm/doc"
)
// +build go1.1
@ -71,43 +68,15 @@ var commands = []*cmd.Command{
helpTestfunc,*/
}
// getAppPath returns application execute path for current process.
func getAppPath() bool {
// Look up executable in PATH variable.
cmd.AppPath, _ = exec.LookPath(path.Base(os.Args[0]))
// Check if run under $GOPATH/bin.
if !doc.IsExist(cmd.AppPath + "docs/") {
paths := doc.GetGOPATH()
for _, p := range paths {
if doc.IsExist(p + "/src/github.com/gpmgoo/gopm/") {
cmd.AppPath = p + "/src/github.com/gpmgo/gopm/"
break
}
}
}
if len(cmd.AppPath) == 0 {
doc.ColorLog("[ERRO] Cannot assign 'AppPath'[ %s ]\n",
"Unable to indicate current execute path")
return false
}
cmd.AppPath = filepath.Dir(cmd.AppPath) + "/"
if runtime.GOOS == "windows" {
// Replace all '\' to '/'.
cmd.AppPath = strings.Replace(cmd.AppPath, "\\", "/", -1)
}
return true
}
// We don't use init() to initialize
// bacause we need to get execute path in runtime.
func initialize() bool {
runtime.GOMAXPROCS(runtime.NumCPU())
// Get application execute path.
if !getAppPath() {
var err error
cmd.AppPath, err = com.GetSrcPath("github.com/gpmgoo/gopm")
if err != nil {
return false
}

Loading…
Cancel
Save