]> Cypherpunks repositories - gostls13.git/commit
cmd/go: avoid use of bufio.Scanner in generate
authorRob Pike <r@golang.org>
Fri, 5 Dec 2014 00:15:38 +0000 (09:15 +0900)
committerRob Pike <r@golang.org>
Fri, 5 Dec 2014 00:15:38 +0000 (09:15 +0900)
commitdd26fc3822e474112e388f51d59a7257361fb72f
tree546407b2cc3b4ca76fd9ee5dcf8c91e5d7ff628c
parentc9d0c812142be1c8f224012f24d111ba46ccdc10
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
src/cmd/go/doc.go
src/cmd/go/generate.go