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

Issue 5713043: code review 5713043: go/build: replace FindTree, ScanDir, Tree, DirInfo with... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 2 months ago by rsc
Modified:
13 years, 2 months ago
Reviewers:
CC:
golang-dev, r, brainman, adg
Visibility:
Public.

Description

go/build: replace FindTree, ScanDir, Tree, DirInfo with Import, Package This is an API change, but one I have been promising would happen when it was clear what the go command needed. This is basically a complete replacement of what used to be here. build.Tree is gone. build.DirInfo is expanded and now called build.Package. build.FindTree is now build.Import(package, srcDir, build.FindOnly). The returned *Package contains information that FindTree returned, but applicable only to a single package. build.ScanDir is now build.ImportDir. build.FindTree+build.ScanDir is now build.Import. The new Import API allows specifying the source directory, in order to resolve local imports (import "./foo") and also allows scanning of packages outside of $GOPATH. They will come back with less information in the Package, but they will still work. The old go/build API exposed both too much and too little. This API is much closer to what the go command needs, and it works well enough in the other places where it is used. Path is gone, so it can no longer be misused. (Fixes issue 2749.) This CL updates clients of go/build other than the go command. The go command changes are in a separate CL, to be submitted at the same time.

Patch Set 1 #

Patch Set 2 : diff -r a6e732d1523e https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r a6e732d1523e https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 4 : diff -r aa7ded1d6fab https://go.googlecode.com/hg/ #

Total comments: 7

Patch Set 5 : diff -r aa7ded1d6fab https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r aa7ded1d6fab https://go.googlecode.com/hg/ #

Patch Set 7 : diff -r 0e0a2d1892f4 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+502 lines, -514 lines) Patch
M src/cmd/api/goapi.go View 1 2 5 chunks +8 lines, -15 lines 0 comments Download
M src/cmd/api/goapi_test.go View 1 2 chunks +1 line, -2 lines 0 comments Download
M src/cmd/godoc/godoc.go View 1 4 chunks +16 lines, -12 lines 0 comments Download
M src/cmd/godoc/main.go View 1 2 3 4 5 6 1 chunk +3 lines, -3 lines 0 comments Download
M src/pkg/exp/types/gcimporter.go View 1 2 5 3 chunks +8 lines, -4 lines 0 comments Download
M src/pkg/go/build/build.go View 1 2 3 4 5 6 14 chunks +410 lines, -129 lines 0 comments Download
M src/pkg/go/build/build_test.go View 1 2 chunks +39 lines, -71 lines 0 comments Download
R src/pkg/go/build/cgotest/cgotest.h View 1 1 chunk +0 lines, -5 lines 0 comments Download
R src/pkg/go/build/cgotest/cgotest.c View 1 1 chunk +0 lines, -9 lines 0 comments Download
R src/pkg/go/build/cgotest/cgotest.go View 1 1 chunk +0 lines, -19 lines 0 comments Download
R src/pkg/go/build/cmdtest/main.go View 1 1 chunk +0 lines, -12 lines 0 comments Download
R src/pkg/go/build/path.go View 1 1 chunk +0 lines, -169 lines 0 comments Download
R src/pkg/go/build/pkgtest/pkgtest.go View 1 1 chunk +0 lines, -13 lines 0 comments Download
R src/pkg/go/build/pkgtest/sqrt_386.s View 1 1 chunk +0 lines, -10 lines 0 comments Download
R src/pkg/go/build/pkgtest/sqrt_386_test.go View 1 1 chunk +0 lines, -1 line 0 comments Download
R src/pkg/go/build/pkgtest/sqrt_amd64.s View 1 1 chunk +0 lines, -9 lines 0 comments Download
R src/pkg/go/build/pkgtest/sqrt_amd64_test.go View 1 1 chunk +0 lines, -1 line 0 comments Download
R src/pkg/go/build/pkgtest/sqrt_arm.s View 1 1 chunk +0 lines, -10 lines 0 comments Download
R src/pkg/go/build/pkgtest/sqrt_arm_test.go View 1 1 chunk +0 lines, -1 line 0 comments Download
R src/pkg/go/build/pkgtest/sqrt_test.go View 1 1 chunk +0 lines, -9 lines 0 comments Download
R src/pkg/go/build/pkgtest/xsqrt_test.go View 1 1 chunk +0 lines, -9 lines 0 comments Download
M src/pkg/go/build/syslist_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
A src/pkg/go/build/testdata/other/file/file.go View 1 1 chunk +5 lines, -0 lines 0 comments Download
A src/pkg/go/build/testdata/other/main.go View 1 1 chunk +11 lines, -0 lines 0 comments Download

Messages

Total messages: 21
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 2 months ago (2012-02-29 20:48:09 UTC) #1
r
http://codereview.appspot.com/5713043/diff/1002/src/pkg/go/build/build.go File src/pkg/go/build/build.go (right): http://codereview.appspot.com/5713043/diff/1002/src/pkg/go/build/build.go#newcode102 src/pkg/go/build/build.go:102: JoinPath func(elem ...string) string this is fine, but it ...
13 years, 2 months ago (2012-02-29 22:12:10 UTC) #2
rsc
On Wed, Feb 29, 2012 at 17:12, <r@golang.org> wrote: > src/pkg/go/build/build.go:102: JoinPath func(elem ...string) string ...
13 years, 2 months ago (2012-02-29 22:16:49 UTC) #3
brainman
http://codereview.appspot.com/5713043/diff/5001/src/pkg/go/build/build.go File src/pkg/go/build/build.go (right): http://codereview.appspot.com/5713043/diff/5001/src/pkg/go/build/build.go#newcode187 src/pkg/go/build/build.go:187: if !strings.HasPrefix(dir, root) { I think we will have ...
13 years, 2 months ago (2012-02-29 22:42:54 UTC) #4
rsc
On Wed, Feb 29, 2012 at 17:42, <alex.brainman@gmail.com> wrote: > I think we will have ...
13 years, 2 months ago (2012-02-29 22:46:43 UTC) #5
brainman
On 2012/02/29 22:46:43, rsc wrote: > On Wed, Feb 29, 2012 at 17:42, <mailto:alex.brainman@gmail.com> wrote: ...
13 years, 2 months ago (2012-02-29 22:52:50 UTC) #6
rsc
I know. Really it should be called RealPath or something like that, but for now ...
13 years, 2 months ago (2012-02-29 22:58:35 UTC) #7
brainman
On 2012/02/29 22:58:35, rsc wrote: > I know. Really it should be called RealPath or ...
13 years, 2 months ago (2012-02-29 23:06:03 UTC) #8
adg
LGTM I was troubled by this package since the beginning. This is much better. On ...
13 years, 2 months ago (2012-03-01 00:21:59 UTC) #9
r
Fixes 3118?
13 years, 2 months ago (2012-03-01 00:28:03 UTC) #10
r
Fixes 2775? http://codereview.appspot.com/5713043/diff/5001/src/pkg/go/build/build.go File src/pkg/go/build/build.go (right): http://codereview.appspot.com/5713043/diff/5001/src/pkg/go/build/build.go#newcode89 src/pkg/go/build/build.go:89: GOROOT string // build Go root the ...
13 years, 2 months ago (2012-03-01 00:37:10 UTC) #11
rsc
On Wed, Feb 29, 2012 at 19:21, Andrew Gerrand <adg@golang.org> wrote: >> I know. Really ...
13 years, 2 months ago (2012-03-01 01:15:20 UTC) #12
brainman
On 2012/03/01 01:15:20, rsc wrote: > ... you really need a higher-level idea, > that ...
13 years, 2 months ago (2012-03-01 01:56:32 UTC) #13
rsc
On Wed, Feb 29, 2012 at 20:56, <alex.brainman@gmail.com> wrote: > For example "drive letter" in ...
13 years, 2 months ago (2012-03-01 04:08:29 UTC) #14
rsc
On Wed, Feb 29, 2012 at 19:28, <r@golang.org> wrote: > Fixes 3118? No, nor 2775, ...
13 years, 2 months ago (2012-03-01 04:09:16 UTC) #15
rsc
Done. On Wed, Feb 29, 2012 at 19:37, <r@golang.org> wrote: > http://codereview.appspot.com/5713043/diff/5001/src/pkg/go/build/build.go#newcode89 > src/pkg/go/build/build.go:89: GOROOT ...
13 years, 2 months ago (2012-03-01 04:13:23 UTC) #16
rsc
Hello golang-dev@googlegroups.com, r@golang.org, alex.brainman@gmail.com, adg@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 2 months ago (2012-03-01 04:14:02 UTC) #17
r
LGTM yay
13 years, 2 months ago (2012-03-01 04:26:32 UTC) #18
brainman
On 2012/03/01 04:08:29, rsc wrote: LGTM > ... > I am not planning to force ...
13 years, 2 months ago (2012-03-01 04:28:06 UTC) #19
rsc
On Wed, Feb 29, 2012 at 23:28, <alex.brainman@gmail.com> wrote: > But you are forcing the ...
13 years, 2 months ago (2012-03-01 04:37:05 UTC) #20
rsc
13 years, 2 months ago (2012-03-01 17:12:12 UTC) #21
*** Submitted as http://code.google.com/p/go/source/detail?r=64311b514185 ***

go/build: replace FindTree, ScanDir, Tree, DirInfo with Import, Package

This is an API change, but one I have been promising would
happen when it was clear what the go command needed.

This is basically a complete replacement of what used to be here.

build.Tree is gone.

build.DirInfo is expanded and now called build.Package.

build.FindTree is now build.Import(package, srcDir, build.FindOnly).
The returned *Package contains information that FindTree returned,
but applicable only to a single package.

build.ScanDir is now build.ImportDir.

build.FindTree+build.ScanDir is now build.Import.

The new Import API allows specifying the source directory,
in order to resolve local imports (import "./foo") and also allows
scanning of packages outside of $GOPATH.  They will come back
with less information in the Package, but they will still work.

The old go/build API exposed both too much and too little.
This API is much closer to what the go command needs,
and it works well enough in the other places where it is
used.  Path is gone, so it can no longer be misused.  (Fixes issue 2749.)

This CL updates clients of go/build other than the go command.
The go command changes are in a separate CL, to be submitted
at the same time.

R=golang-dev, r, alex.brainman, adg
CC=golang-dev
http://codereview.appspot.com/5713043
Sign in to reply to this message.

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