1
0
mirror of https://github.com/golang/go synced 2024-11-26 09:58:04 -07:00

cmd/go: make vet work with -overlay

It never worked before, an apparent oversight.
This will also make tests work, since tests run vet.

The new FIPS mode will use overlays, so this was
keeping go test from working in that mode.

Fixes #44957.

Change-Id: I3a77846b3b3f9a3a53118aaece93ee93214a36a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/629199
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Russ Cox 2024-11-17 16:52:25 -05:00
parent d90ce588ea
commit d9de8ba83c
2 changed files with 15 additions and 4 deletions

View File

@ -858,7 +858,7 @@ OverlayLoop:
embed.Patterns = p.Internal.Embed
embed.Files = make(map[string]string)
for _, file := range p.EmbedFiles {
embed.Files[file] = filepath.Join(p.Dir, file)
embed.Files[file] = fsys.Actual(filepath.Join(p.Dir, file))
}
js, err := json.MarshalIndent(&embed, "", "\t")
if err != nil {
@ -1175,9 +1175,9 @@ func buildVetConfig(a *Action, srcfiles []string) {
ID: a.Package.ImportPath,
Compiler: cfg.BuildToolchainName,
Dir: a.Package.Dir,
GoFiles: mkAbsFiles(a.Package.Dir, gofiles),
NonGoFiles: mkAbsFiles(a.Package.Dir, nongofiles),
IgnoredFiles: mkAbsFiles(a.Package.Dir, ignored),
GoFiles: actualFiles(mkAbsFiles(a.Package.Dir, gofiles)),
NonGoFiles: actualFiles(mkAbsFiles(a.Package.Dir, nongofiles)),
IgnoredFiles: actualFiles(mkAbsFiles(a.Package.Dir, ignored)),
ImportPath: a.Package.ImportPath,
ImportMap: make(map[string]string),
PackageFile: make(map[string]string),
@ -3383,6 +3383,15 @@ func mkAbsFiles(dir string, files []string) []string {
return abs
}
// actualFiles applies fsys.Actual to the list of files.
func actualFiles(files []string) []string {
a := make([]string, len(files))
for i, f := range files {
a[i] = fsys.Actual(f)
}
return a
}
// passLongArgsInResponseFiles modifies cmd such that, for
// certain programs, long arguments are passed in "response files", a
// file on disk with the arguments, with one arg per line. An actual

View File

@ -22,6 +22,8 @@ go build -overlay overlay.json -o print_abspath$GOEXE ./printpath
exec ./print_abspath$GOEXE
stdout $WORK[/\\]gopath[/\\]src[/\\]m[/\\]printpath[/\\]main.go
go vet -overlay overlay.json ./printpath
go build -overlay overlay.json -o print_trimpath$GOEXE -trimpath ./printpath
exec ./print_trimpath$GOEXE
stdout ^m[/\\]printpath[/\\]main.go