]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.12] cmd/go: fix the default build output name for versioned binaries
authorDmitri Shuralyov <dmitshur@golang.org>
Thu, 21 Mar 2019 17:31:32 +0000 (13:31 -0400)
committerDmitri Shuralyov <dmitshur@golang.org>
Wed, 27 Mar 2019 23:29:06 +0000 (23:29 +0000)
commitaeb9d03e4a570890b32aafd7aee27b00946ebbe4
treea6c5ffad998ed317a2647432bfe6043fb9ca34d8
parent827c5d5355b0753f144c27fd5d1d5e62ffc2fb7e
[release-branch.go1.12] cmd/go: fix the default build output name for versioned binaries

This change is a re-apply of the reverted CL 140863 with changes to
address issue #30821. Specifically, path.Split continues to be used
to split the '/'-separated import path, rather than filepath.Split.

Document the algorithm for how the default executable name is determined
in DefaultExecName.

Rename a variable returned from os.Stat from bs to fi for consistency.

CL 140863 factored out the logic to determine the default executable
name from the Package.load method into a DefaultExecName function,
and started using it in more places to avoid having to re-implement
the logic everywhere it's needed. Most previous callers already computed
the default executable name based on the import path. The load.Package
method, before CL 140863, was the exception, in that it used the p.Dir
value in GOPATH mode instead. There was a NOTE(rsc) comment that it
should be equivalent to use import path, but it was too late in Go 1.11
cycle to risk implementing that change.

This is part 1, a more conservative change for backporting to Go 1.12.2,
and it keeps the original behavior of splitting on p.Dir in GOPATH mode.
Part 2 will address the NOTE(rsc) comment and modify behavior in
Package.load to always use DefaultExecName which splits the import path
rather than directory. It is intended to be included in Go 1.13.

Updates #27283
Updates #26869
Updates #30821
Fixes #30266

Change-Id: Ib1ebb95acba7c85c24e3a55c40cdf48405af34f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/167503
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
(cherry picked from commit 94563de87fad642677ffc62a4a82766597e39123)
Reviewed-on: https://go-review.googlesource.com/c/go/+/168958
Run-TryBot: Dmitri Shuralyov <dmitshur@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]