]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.4] cmd/go: avoid use of bufio.Scanner in generate
authorRuss Cox <rsc@golang.org>
Fri, 5 Dec 2014 04:42:16 +0000 (23:42 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 5 Dec 2014 04:42:16 +0000 (23:42 -0500)
commit7aead4c6fd70134f9714a343a8131e51f1c3e1b0
treee5b49987c2c39c22c9f2ed43d9e868e1ab8805cf
parent19bbff8a328d8c2a93b02ba12bbe5491e28e5508
[release-branch.go1.4] cmd/go: avoid use of bufio.Scanner in generate

««« CL 182970043 / 573a7b5178c4
cmd/go: avoid use of bufio.Scanner in generate

Scanner can't handle stupid long lines and there are
reports of stupid long lines in production.

Note the issue isn't long "//go:generate" lines, but
any long line in any Go source file.

To be fair, if you're going to have a stupid long line
it's not a bad bet you'll want to run it through go
generate, because it's some embeddable asset that
has been machine generated. (One could ask why
that generation process didn't add a newline or two,
but we should cope anyway.)

Rewrite the file scanner in "go generate" so it can
handle arbitrarily long lines, and only stores in memory
those lines that start "//go:generate".

Also: Adjust the documentation to make clear that it
does not parse the file.

Fixes #9143.
Fixes #9196.

LGTM=rsc, dominik.honnef
R=rsc, cespare, minux, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/182970043
»»»

TBR=r
CC=golang-codereviews
https://golang.org/cl/183060044
src/cmd/go/doc.go
src/cmd/go/generate.go