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

Issue 124940043: code review 124940043: cmd/go, go/build: implement import comment checking (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 9 months ago by rsc
Modified:
9 years, 9 months ago
Reviewers:
r
CC:
josharian, golang-codereviews
Visibility:
Public.

Description

cmd/go, go/build: implement import comment checking See golang.org/s/go14customimport for design. Added case to deps_test to allow go/build to import regexp. Not a new dependency, because go/build already imports go/doc which imports regexp. Fixes issue 7453.

Patch Set 1 #

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

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

Total comments: 1

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

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

Total comments: 3

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+206 lines, -14 lines) Patch
M src/cmd/go/pkg.go View 1 2 3 4 5 1 chunk +4 lines, -1 line 0 comments Download
M src/cmd/go/test.bash View 1 1 chunk +36 lines, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/bad.go View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/conflict.go View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/src/bad/bad.go View 1 2 1 chunk +1 line, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/src/conflict/a.go View 1 2 1 chunk +1 line, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/src/conflict/b.go View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/src/works/x/x.go View 1 2 1 chunk +1 line, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/src/works/x/x1.go View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/src/wrongplace/x.go View 1 2 1 chunk +1 line, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/works.go View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
A src/cmd/go/testdata/importcom/wrongplace.go View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
M src/pkg/go/build/build.go View 1 2 3 5 chunks +148 lines, -13 lines 0 comments Download

Messages

Total messages: 16
rsc
Hello r (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
9 years, 9 months ago (2014-08-08 19:06:48 UTC) #1
r
surely doc.go needs to be updated.
9 years, 9 months ago (2014-08-08 19:33:56 UTC) #2
r
https://codereview.appspot.com/124940043/diff/40001/src/pkg/go/build/build.go File src/pkg/go/build/build.go (right): https://codereview.appspot.com/124940043/diff/40001/src/pkg/go/build/build.go#newcode793 src/pkg/go/build/build.go:793: importPattern = `\A` + spaceOrComment + `*package[ \t\r\v\f]+[\p{L}0-9_]+[ \t\r\v\f]*//[ ...
9 years, 9 months ago (2014-08-08 19:39:40 UTC) #3
rsc
On 2014/08/08 19:39:40, r wrote: > https://codereview.appspot.com/124940043/diff/40001/src/pkg/go/build/build.go > File src/pkg/go/build/build.go (right): > > https://codereview.appspot.com/124940043/diff/40001/src/pkg/go/build/build.go#newcode793 > ...
9 years, 9 months ago (2014-08-08 20:43:59 UTC) #4
r
It seems wrong to me that package x // import "a" works but package x ...
9 years, 9 months ago (2014-08-08 20:47:41 UTC) #5
rsc
On Fri, Aug 8, 2014 at 4:47 PM, <r@golang.org> wrote: > It seems wrong to ...
9 years, 9 months ago (2014-08-08 20:52:36 UTC) #6
r
The XXX (what's it called? an import qualifier) is specified with a comment that is ...
9 years, 9 months ago (2014-08-08 20:59:46 UTC) #7
r
Moreover, if there is a comment but it's not in this form, there should probably ...
9 years, 9 months ago (2014-08-08 21:02:30 UTC) #8
rsc
There's a tension between correcting mistakes and disallowing all code that has a comment there ...
9 years, 9 months ago (2014-08-12 17:43:14 UTC) #9
rsc
PTAL I have updated golang.org/s/go14customimport to give the new rule, and I have updated the ...
9 years, 9 months ago (2014-08-12 18:14:02 UTC) #10
r
SGTM. The import keyword is a required part of the specification. -rob On Tue, Aug ...
9 years, 9 months ago (2014-08-12 18:18:39 UTC) #11
josharian
https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go File src/cmd/go/pkg.go (right): https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go#newcode425 src/cmd/go/pkg.go:425: // expandNoGo expands build.NoGoError's message to say whether there ...
9 years, 9 months ago (2014-08-12 18:20:56 UTC) #12
r
LGTM https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go File src/cmd/go/pkg.go (right): https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go#newcode270 src/cmd/go/pkg.go:270: err = fmt.Errorf("%s contains package %q", bp.Dir, bp.ImportComment) ...
9 years, 9 months ago (2014-08-12 18:24:51 UTC) #13
rsc
https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go File src/cmd/go/pkg.go (right): https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go#newcode270 src/cmd/go/pkg.go:270: err = fmt.Errorf("%s contains package %q", bp.Dir, bp.ImportComment) Submitted ...
9 years, 9 months ago (2014-08-12 21:40:21 UTC) #14
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=d4469d39943e *** cmd/go, go/build: implement import comment checking See golang.org/s/go14customimport for design. ...
9 years, 9 months ago (2014-08-12 21:41:07 UTC) #15
r
9 years, 9 months ago (2014-08-12 21:43:46 UTC) #16
Message was sent while issue was closed.
On 2014/08/12 21:40:21, rsc wrote:
> https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go
> File src/cmd/go/pkg.go (right):
> 
>
https://codereview.appspot.com/124940043/diff/70014/src/cmd/go/pkg.go#newcode270
> src/cmd/go/pkg.go:270: err = fmt.Errorf("%s contains package %q", bp.Dir,
> bp.ImportComment)
> Submitted as is, but I'm happy to try to iterate on this separately.
> I assume the main objection is package %q vs package path %q.
> (Can't use %q for directories because of Windows.)
> 
> Right now it prints something like
> 
> github.com/rsc/pdf: /Users/rsc/g/src/github.com/rsc/pdf contains package
> "rsc.io/pdf"
> 
> If it said:
> 
> github.com/rsc/pdf: package in directory /Users/rsc/g/src/github.com/rsc/pdf
has
> package path "rsc.io/pdf"
> 
> then I'm a little worried about not getting across that it's the source code
> that's the problem. Maybe:
> 
> github.com/rsc/pdf: code in directory /Users/rsc/g/src/github.com/rsc/pdf
> expects import "rsc.io/pdf"
> 
> ?

I like your final wording.
Sign in to reply to this message.

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