]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.12] cmd/go: fix the default build output name for versioned binaries
authorHana Kim <hyangah@gmail.com>
Mon, 14 Jan 2019 16:13:34 +0000 (11:13 -0500)
committerAndrew Bonventre <andybons@golang.org>
Wed, 13 Mar 2019 21:18:41 +0000 (21:18 +0000)
commit746edd459d26f07f69fcb6bddfafaaae7c5a2911
tree2893763cd91a9d0f7445fb362ee421ae6ab4b688
parentad8ebb9e85131aa1f37664b79f6f02415ba1a6e6
[release-branch.go1.12] cmd/go: fix the default build output name for versioned binaries

`go build` has chosen the last element of the package import path
as the default output name when -o option is given. That caused
the output of a package build when the module root is the major
version component such as 'v2'.

A similar issue involving `go install` was fixed in
https://golang.org/cl/128900. This CL refactors the logic added
with the change and makes it available as
internal/load.DefaultExecName.

This CL makes 'go test' to choose the right default test binary
name when the tested package is in the module root. (E.g.,
instead of v2.test, choose pkg.test for the test of 'path/pkg/v2')

Fixes #27283
Fixes #30266

Change-Id: I6905754f0906db46e3ce069552715f45356913ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/140863
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit bf94fc3ae387fc09929443393741919fac6727af)
Reviewed-on: https://go-review.googlesource.com/c/go/+/167384
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/test/test.go
src/cmd/go/internal/work/build.go
src/cmd/go/testdata/mod/rsc.io_fortune_v2_v2.0.0.txt
src/cmd/go/testdata/script/mod_build_versioned.txt [new file with mode: 0644]