-o compatible with go1.11,go1.2

This commit is contained in:
lyyyuna 2020-06-13 20:11:09 +08:00
parent 3717c2d29f
commit be87886315

View File

@ -23,6 +23,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings"
) )
// Build is to describe the building/installing process of a goc build/install // 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)) cmd.Env = append(os.Environ(), fmt.Sprintf("GOPATH=%v", b.NewGOPATH))
} }
log.Printf("go build cmd is: %v", cmd.Args)
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
log.Fatalf("Fail to execute: %v. The error is: %v, the stdout/stderr is: %v", cmd.Args, err, string(out)) 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
if outputDir == "" { 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) abs, err := filepath.Abs(outputDir)
if err != nil { if err != nil {