]> Cypherpunks repositories - gostls13.git/commit
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)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 13 Mar 2019 20:18:44 +0000 (20:18 +0000)
commitbf94fc3ae387fc09929443393741919fac6727af
tree35309b175f08722e2cd5985d321b816488f0181e
parent0a04c0430e9671bd531a2928a8416424da1e3dde
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.

Change-Id: I6905754f0906db46e3ce069552715f45356913ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/140863
Reviewed-by: Bryan C. Mills <bcmills@google.com>
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]