tg.run("run", tg.path("src/p3/p3.go"))
tg.grepStdout("hello from p1", "did not see message from p1")
+
+ tg.tempFile("src/p4/p4.go", `package main`)
+ tg.tempFile("src/p4/p4not.go", `//go:binary-only-package
+
+ // +build asdf
+
+ package main
+ `)
+ tg.run("list", "-f", "{{.BinaryOnly}}", "p4")
+ tg.grepStdout("false", "did not see BinaryOnly=false for p4")
}
// Issue 16050.
}
// Look for +build comments to accept or reject the file.
- if !ctxt.shouldBuild(data, allTags, binaryOnly) && !ctxt.UseAllFiles {
+ var sawBinaryOnly bool
+ if !ctxt.shouldBuild(data, allTags, &sawBinaryOnly) && !ctxt.UseAllFiles {
return
}
+ if binaryOnly != nil && sawBinaryOnly {
+ *binaryOnly = true
+ }
match = true
return
}
//
// marks the file as applicable only on Windows and Linux.
//
-// If shouldBuild finds a //go:binary-only-package comment in a file that
-// should be built, it sets *binaryOnly to true. Otherwise it does
-// not change *binaryOnly.
+// If shouldBuild finds a //go:binary-only-package comment in the file,
+// it sets *binaryOnly to true. Otherwise it does not change *binaryOnly.
//
func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binaryOnly *bool) bool {
sawBinaryOnly := false