Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Issue 182970043: code review 182970043: cmd/go: avoid use of bufio.Scanner in generate (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 11 months ago by r
Modified:
9 years, 11 months ago
Reviewers:
Dominik Honnef, gobot, rsc, dave
CC:
rsc, cespare, minux, Dominik Honnef, golang-codereviews
Visibility:
Public.

Description

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 issue 9143. Fixes issue 9196.

Patch Set 1 #

Total comments: 1

Patch Set 2 : diff -r ffe33f1f1f17bf7d9bd14d8a8931dc905a75d011 https://code.google.com/p/go #

Patch Set 3 : diff -r ffe33f1f1f17bf7d9bd14d8a8931dc905a75d011 https://code.google.com/p/go #

Total comments: 1

Patch Set 4 : diff -r ffe33f1f1f17bf7d9bd14d8a8931dc905a75d011 https://code.google.com/p/go #

Patch Set 5 : diff -r ffe33f1f1f17bf7d9bd14d8a8931dc905a75d011 https://code.google.com/p/go #

Patch Set 6 : diff -r 871468f5ceaf21cccedbae34bb40abc34d0d1737 https://code.google.com/p/go #

Patch Set 7 : diff -r 871468f5ceaf21cccedbae34bb40abc34d0d1737 https://code.google.com/p/go #

Patch Set 8 : diff -r 871468f5ceaf21cccedbae34bb40abc34d0d1737 https://code.google.com/p/go #

Patch Set 9 : diff -r 871468f5ceaf21cccedbae34bb40abc34d0d1737 https://code.google.com/p/go #

Patch Set 10 : diff -r d56c648b069f441b8bc2387265cdc2d781c697fa https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+70 lines, -22 lines) Patch
M src/cmd/go/doc.go View 1 2 3 4 5 6 7 8 1 chunk +14 lines, -7 lines 0 comments Download
M src/cmd/go/generate.go View 1 2 3 4 5 3 chunks +56 lines, -15 lines 0 comments Download

Messages

Total messages: 23
r
Hello rsc (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go
9 years, 11 months ago (2014-12-02 04:55:20 UTC) #1
rsc
LGTM what you have is fine, but it can be shortened with ReadSlice. https://codereview.appspot.com/182970043/diff/1/src/cmd/go/generate.go File ...
9 years, 11 months ago (2014-12-02 05:30:13 UTC) #2
r
Hello rsc@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
9 years, 11 months ago (2014-12-02 05:49:09 UTC) #3
r
Not sure I like yours much better, but I'll take it. -rob On Tue, Dec ...
9 years, 11 months ago (2014-12-02 05:49:51 UTC) #4
rsc
LGTM https://codereview.appspot.com/182970043/diff/40001/src/cmd/go/generate.go File src/cmd/go/generate.go (right): https://codereview.appspot.com/182970043/diff/40001/src/cmd/go/generate.go#newcode185 src/cmd/go/generate.go:185: buf := make([]byte, 2048) Delete. Declare var buf ...
9 years, 11 months ago (2014-12-02 06:13:41 UTC) #5
r
Hello rsc@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
9 years, 11 months ago (2014-12-03 02:26:35 UTC) #6
cespare
Why is there an unrelated documentation change (concerning get -f) in this CL?
9 years, 11 months ago (2014-12-03 02:44:19 UTC) #7
r
Should be gone now. I was behind tip and my doc.go was old. I synced ...
9 years, 11 months ago (2014-12-03 02:47:43 UTC) #8
minux
It seems you still need to run mkdoc.sh, doc.go in Patch Set 6 doesn't contain ...
9 years, 11 months ago (2014-12-03 02:55:08 UTC) #9
r
Done.
9 years, 11 months ago (2014-12-03 03:26:55 UTC) #10
r
Hello rsc@golang.org, cespare@gmail.com, minux@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
9 years, 11 months ago (2014-12-03 03:36:07 UTC) #11
Dominik Honnef
On 2014/12/03 03:36:07, r wrote: > Hello mailto:rsc@golang.org, mailto:cespare@gmail.com, mailto:minux@golang.org (cc: > mailto:golang-codereviews@googlegroups.com), > > ...
9 years, 11 months ago (2014-12-03 09:47:34 UTC) #12
r
I have no idea what's going on. I am at tip, synced, built the command, ...
9 years, 11 months ago (2014-12-03 11:38:53 UTC) #13
r
Hello rsc@golang.org, cespare@gmail.com, minux@golang.org, dominik.honnef@gmail.com (cc: golang-codereviews@googlegroups.com), Please take another look.
9 years, 11 months ago (2014-12-03 11:39:40 UTC) #14
r
All this for a CL that won't ever be checked in to this repo. -rob ...
9 years, 11 months ago (2014-12-03 11:40:17 UTC) #15
Dominik Honnef
LGTM On 2014/12/03 11:40:17, r wrote: > All this for a CL that won't ever ...
9 years, 11 months ago (2014-12-03 12:14:03 UTC) #16
Dominik Honnef
LGTM On 2014/12/03 11:40:17, r wrote: > All this for a CL that won't ever ...
9 years, 11 months ago (2014-12-03 12:14:10 UTC) #17
rsc
I think this should probably go into the release. //go:generate is new in 1.4, might ...
9 years, 11 months ago (2014-12-04 16:29:13 UTC) #18
r
*** Submitted as https://code.google.com/p/go/source/detail?r=573a7b5178c4 *** cmd/go: avoid use of bufio.Scanner in generate Scanner can't handle ...
9 years, 11 months ago (2014-12-05 00:15:46 UTC) #19
gobot
This CL appears to have broken the solaris-amd64-smartos builder. See http://build.golang.org/log/9ffdfbe8dbc2594203d37ab4768cd75e49484732
9 years, 11 months ago (2014-12-05 00:17:29 UTC) #20
dave_cheney.net
This is a real failure, --- FAIL: TestGenerateCommandParse (0.00s) panic: runtime error: slice bounds out ...
9 years, 11 months ago (2014-12-05 00:19:29 UTC) #21
minux
Seems real: --- FAIL: TestGenerateCommandParse (0.00s) panic: runtime error: slice bounds out of range [recovered] ...
9 years, 11 months ago (2014-12-05 00:19:43 UTC) #22
r
9 years, 11 months ago (2014-12-05 00:20:51 UTC) #23
I ran go test a hundred times yesterday but somehow I needed to run it once
more. Will fix.

-rob


On Fri, Dec 5, 2014 at 9:17 AM, <gobot@golang.org> wrote:

> This CL appears to have broken the solaris-amd64-smartos builder.
> See http://build.golang.org/log/9ffdfbe8dbc2594203d37ab4768cd75e49484732
>
> https://codereview.appspot.com/182970043/
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b