diff options
author | Jordi Martin <jordimartin@gmail.com> | 2019-10-04 11:56:26 +0000 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-10-04 17:30:40 +0000 |
commit | 3ce29b44bb8eaecbd5000202564ad4f52ad1cf69 (patch) | |
tree | c6b4cc23dac62e659b56fee443f320b9148d1b88 /src/cmd/go/internal/work/build.go | |
parent | 43a4c61e125d184a8c9dac2d55cfa4ae31153fe8 (diff) | |
download | go-3ce29b44bb8eaecbd5000202564ad4f52ad1cf69.tar.gz go-3ce29b44bb8eaecbd5000202564ad4f52ad1cf69.zip |
cmd/go: set expected filename when building a local package with -o is pointing to a folder
In the local package build process, when -o is pointing to an existing folder, the object
the filename is generated from files listed on the command line like when the -o is
not pointing to a folder instead of using the `importPath` that is going to be `command-line-arguments`
Fixes #34535
Change-Id: I09a7609c17a2ccdd83da32f01247c0ef473dea1e
GitHub-Last-Rev: b3224226a3914aa2573e47a6daff9fd5a48ca225
GitHub-Pull-Request: golang/go#34562
Reviewed-on: https://go-review.googlesource.com/c/go/+/197544
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/work/build.go')
-rw-r--r-- | src/cmd/go/internal/work/build.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 1fc47a36c7..54b049b68f 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -329,7 +329,7 @@ func runBuild(cmd *base.Command, args []string) { explicitO := len(cfg.BuildO) > 0 if len(pkgs) == 1 && pkgs[0].Name == "main" && cfg.BuildO == "" { - cfg.BuildO = load.DefaultExecName(pkgs[0].ImportPath) + cfg.BuildO = pkgs[0].DefaultExecName() cfg.BuildO += cfg.ExeSuffix } @@ -373,7 +373,8 @@ func runBuild(cmd *base.Command, args []string) { if p.Name != "main" { continue } - p.Target = filepath.Join(cfg.BuildO, load.DefaultExecName(p.ImportPath)) + + p.Target = filepath.Join(cfg.BuildO, p.DefaultExecName()) p.Target += cfg.ExeSuffix p.Stale = true p.StaleReason = "build -o flag in use" @@ -595,7 +596,7 @@ func InstallPackages(patterns []string, pkgs []*load.Package) { if len(patterns) == 0 && len(pkgs) == 1 && pkgs[0].Name == "main" { // Compute file 'go build' would have created. // If it exists and is an executable file, remove it. - targ := load.DefaultExecName(pkgs[0].ImportPath) + targ := pkgs[0].DefaultExecName() targ += cfg.ExeSuffix if filepath.Join(pkgs[0].Dir, targ) != pkgs[0].Target { // maybe $GOBIN is the current directory fi, err := os.Stat(targ) |