]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix //go:binary-only-package check
authorRuss Cox <rsc@golang.org>
Tue, 24 May 2016 00:34:39 +0000 (20:34 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 24 May 2016 13:54:24 +0000 (13:54 +0000)
The use of a prefix check was too liberal.
Noted in review after submit.

Change-Id: I4fe1df660997efd225609e818040b8392fab79f0
Reviewed-on: https://go-review.googlesource.com/23375
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/go_test.go
src/go/build/build.go

index b667396761937444c76b8356fa03b0f150940cd1..987021ecca97b05d809f4954ed02a818bc895cd3 100644 (file)
@@ -2804,7 +2804,8 @@ func TestBinaryOnlyPackages(t *testing.T) {
        os.Remove(tg.path("src/p1/p1.go"))
        tg.mustNotExist(tg.path("src/p1/p1.go"))
 
-       tg.tempFile("src/p2/p2.go", `
+       tg.tempFile("src/p2/p2.go", `//go:binary-only-packages-are-not-great
+
                package p2
                import "p1"
                func F() { p1.F(true) }
index fa258d3dc671a4d0f8a643fc34fdc08ad78f45c0..9706b8b6b31d6298ee2f18c3639806925911df24 100644 (file)
@@ -1151,7 +1151,7 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binary
                }
                line = bytes.TrimSpace(line)
                if bytes.HasPrefix(line, slashslash) {
-                       if bytes.HasPrefix(line, binaryOnlyComment) {
+                       if bytes.Equal(line, binaryOnlyComment) {
                                sawBinaryOnly = true
                        }
                        line = bytes.TrimSpace(line[len(slashslash):])