Example #1
0
File: cmd.go Project: swan-go/gopm
func execCmd(gopath, curPath string, args ...string) error {
	oldGopath := os.Getenv("GOPATH")
	log.Info("Setting GOPATH to %s", gopath)

	sep := ":"
	if runtime.GOOS == "windows" {
		sep = ";"
	}

	if err := os.Setenv("GOPATH", gopath+sep+oldGopath); err != nil {
		if setting.LibraryMode {
			return fmt.Errorf("Fail to setting GOPATH: %v", err)
		}
		log.Error("", "Fail to setting GOPATH:")
		log.Fatal("", "\t"+err.Error())
	}
	if setting.HasGOPATHSetting {
		defer func() {
			log.Info("Setting GOPATH back to %s", oldGopath)
			os.Setenv("GOPATH", oldGopath)
		}()
	}

	cmd := exec.Command(args[0], args[1:]...)
	cmd.Dir = curPath
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	log.Info("===== application outputs start =====\n")

	err := cmd.Run()

	log.Info("====== application outputs end ======")
	return err
}
Example #2
0
File: gopm.go Project: swan-go/gopm
func main() {
	setting.LibraryMode = false
	if err := lib.Run(os.Args); err.HasError {
		if err.Fatal != nil {
			log.Fatal("%v", err.Fatal)
		}
		for _, e := range err.Errors {
			log.Error("%v", e)
		}
	}
}
Example #3
0
File: http.go Project: swan-go/gopm
func (t *transport) SetProxy(proxy string) error {
	if len(proxy) == 0 {
		return nil
	}

	proxyUrl, err := url.Parse(proxy)
	if err != nil {
		if setting.LibraryMode {
			return fmt.Errorf("Fail to set HTTP proxy: %v", err)
		}
		log.Error("", "Fail to set HTTP proxy:")
		log.Fatal("", "\t"+err.Error())
	}
	t.t.Proxy = http.ProxyURL(proxyUrl)
	return nil
}
Example #4
0
func (n *Node) CopyToGopath() error {
	if n.HasVcs() {
		log.Warn("Package in GOPATH has version control: %s", n.RootPath)
		return nil
	}

	os.RemoveAll(n.InstallGopath)
	if err := base.CopyDir(n.InstallPath, n.InstallGopath); err != nil {
		if setting.LibraryMode {
			return fmt.Errorf("Fail to copy to GOPATH: %v", err)
		}
		log.Error("", "Fail to copy to GOPATH:")
		log.Fatal("", "\t"+err.Error())
	}
	log.Info("Package copied to GOPATH: %s", n.RootPath)
	return nil
}