From be87886315c59b77efee385272ceae6ec6d2347f Mon Sep 17 00:00:00 2001 From: lyyyuna Date: Sat, 13 Jun 2020 20:11:09 +0800 Subject: [PATCH] -o compatible with go1.11,go1.2 --- pkg/build/build.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/build/build.go b/pkg/build/build.go index d4c0ebd..cf80fcd 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -23,6 +23,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" ) // Build is to describe the building/installing process of a goc build/install @@ -67,6 +68,7 @@ func (b *Build) Build() { cmd.Env = append(os.Environ(), fmt.Sprintf("GOPATH=%v", b.NewGOPATH)) } + log.Printf("go build cmd is: %v", cmd.Args) out, err := cmd.CombinedOutput() if err != nil { log.Fatalf("Fail to execute: %v. The error is: %v, the stdout/stderr is: %v", cmd.Args, err, string(out)) @@ -83,7 +85,10 @@ func (b *Build) determineOutputDir(outputDir string) string { } // if if outputDir == "" { - return curWorkingDir + _, last := filepath.Split(curWorkingDir) + // replace "_" with "-" in the import path + last = strings.ReplaceAll(last, "_", "-") + return filepath.Join(curWorkingDir, last) } abs, err := filepath.Abs(outputDir) if err != nil {