Skip to content

Commit d9de8ba

Browse files
committed
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 <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent d90ce58 commit d9de8ba

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/cmd/go/internal/work/exec.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ OverlayLoop:
858858
embed.Patterns = p.Internal.Embed
859859
embed.Files = make(map[string]string)
860860
for _, file := range p.EmbedFiles {
861-
embed.Files[file] = filepath.Join(p.Dir, file)
861+
embed.Files[file] = fsys.Actual(filepath.Join(p.Dir, file))
862862
}
863863
js, err := json.MarshalIndent(&embed, "", "\t")
864864
if err != nil {
@@ -1175,9 +1175,9 @@ func buildVetConfig(a *Action, srcfiles []string) {
11751175
ID: a.Package.ImportPath,
11761176
Compiler: cfg.BuildToolchainName,
11771177
Dir: a.Package.Dir,
1178-
GoFiles: mkAbsFiles(a.Package.Dir, gofiles),
1179-
NonGoFiles: mkAbsFiles(a.Package.Dir, nongofiles),
1180-
IgnoredFiles: mkAbsFiles(a.Package.Dir, ignored),
1178+
GoFiles: actualFiles(mkAbsFiles(a.Package.Dir, gofiles)),
1179+
NonGoFiles: actualFiles(mkAbsFiles(a.Package.Dir, nongofiles)),
1180+
IgnoredFiles: actualFiles(mkAbsFiles(a.Package.Dir, ignored)),
11811181
ImportPath: a.Package.ImportPath,
11821182
ImportMap: make(map[string]string),
11831183
PackageFile: make(map[string]string),
@@ -3383,6 +3383,15 @@ func mkAbsFiles(dir string, files []string) []string {
33833383
return abs
33843384
}
33853385

3386+
// actualFiles applies fsys.Actual to the list of files.
3387+
func actualFiles(files []string) []string {
3388+
a := make([]string, len(files))
3389+
for i, f := range files {
3390+
a[i] = fsys.Actual(f)
3391+
}
3392+
return a
3393+
}
3394+
33863395
// passLongArgsInResponseFiles modifies cmd such that, for
33873396
// certain programs, long arguments are passed in "response files", a
33883397
// file on disk with the arguments, with one arg per line. An actual

src/cmd/go/testdata/script/build_overlay.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ go build -overlay overlay.json -o print_abspath$GOEXE ./printpath
2222
exec ./print_abspath$GOEXE
2323
stdout $WORK[/\\]gopath[/\\]src[/\\]m[/\\]printpath[/\\]main.go
2424

25+
go vet -overlay overlay.json ./printpath
26+
2527
go build -overlay overlay.json -o print_trimpath$GOEXE -trimpath ./printpath
2628
exec ./print_trimpath$GOEXE
2729
stdout ^m[/\\]printpath[/\\]main.go

0 commit comments

Comments
 (0)