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 }
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) } } }
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 }
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 }