Skip to content

Commit 16fec19

Browse files
committed
[release-branch.go1.17] [tailscale1.17] go/build: ignore package main files in TestDependencies
The tree has package main files scattered around in it for the purposes of running go generate. They're all marked "// +build ignore", which gets special handling in TestDependencies. It would be nice to be able to use other build tags, such as "generate", as suggested by the go generate design doc. Plus the build tag syntax is changing. This change skips all "package main" files. By definition these aren't importable, so they can't contribute to the dependency tree. We can't quite eliminate the "// +build ignore" check, as it is used by packages runtime and syscall. But it's still a step in the right direction. Change-Id: Ib9449acfdba75f570b87a4200afe944910d76222 Reviewed-on: https://go-review.googlesource.com/c/go/+/339592 Trust: Josh Bleecher Snyder <[email protected]> Run-TryBot: Josh Bleecher Snyder <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> (cherry picked from https://golang.org/cl/339592)
1 parent e44d304 commit 16fec19

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/go/build/deps_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ func findImports(pkg string) ([]string, error) {
652652
if err != nil {
653653
return nil, fmt.Errorf("reading %v: %v", name, err)
654654
}
655+
if info.parsed.Name.Name == "main" {
656+
continue
657+
}
655658
if bytes.Contains(info.header, buildIgnore) {
656659
continue
657660
}

0 commit comments

Comments
 (0)