Commit 8e724e7b authored by Russ Cox's avatar Russ Cox

cmd/go: fix //go:binary-only-package check

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: default avatarAndrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 12610236
...@@ -2804,7 +2804,8 @@ func TestBinaryOnlyPackages(t *testing.T) { ...@@ -2804,7 +2804,8 @@ func TestBinaryOnlyPackages(t *testing.T) {
os.Remove(tg.path("src/p1/p1.go")) os.Remove(tg.path("src/p1/p1.go"))
tg.mustNotExist(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 package p2
import "p1" import "p1"
func F() { p1.F(true) } func F() { p1.F(true) }
......
...@@ -1151,7 +1151,7 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binary ...@@ -1151,7 +1151,7 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool, binary
} }
line = bytes.TrimSpace(line) line = bytes.TrimSpace(line)
if bytes.HasPrefix(line, slashslash) { if bytes.HasPrefix(line, slashslash) {
if bytes.HasPrefix(line, binaryOnlyComment) { if bytes.Equal(line, binaryOnlyComment) {
sawBinaryOnly = true sawBinaryOnly = true
} }
line = bytes.TrimSpace(line[len(slashslash):]) line = bytes.TrimSpace(line[len(slashslash):])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment