From 2cc0f2209653f9f6931e0c3a1fb63e581a0fe87f Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Fri, 13 May 2016 11:10:29 +0900 Subject: [PATCH] Revert "cmd/build: reject non-existant directories in ImportDir" This reverts commit 7af2ce3f159760033c903b3730bfb5995b4edd40. The commit had a wrong prefix in the description line, probably misreconginized something. As a result it broke golang.org/x/tools/godoc and golang.org/x/tools/cmd/godoc like the following: --- FAIL: TestCLI (10.90s) --- FAIL: TestWeb (13.74s) FAIL FAIL golang.org/x/tools/cmd/godoc 36.428s --- FAIL: TestCommandLine (0.00s) FAIL FAIL golang.org/x/tools/godoc 0.068s Change-Id: I362a862a4ded8592dec7488a28e7a256adee148f Reviewed-on: https://go-review.googlesource.com/23076 Run-TryBot: Mikio Hara Reviewed-by: Andrew Gerrand --- src/go/build/build.go | 6 +----- src/go/build/build_test.go | 11 ----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/go/build/build.go b/src/go/build/build.go index 0818aa0501..fa258d3dc6 100644 --- a/src/go/build/build.go +++ b/src/go/build/build.go @@ -403,11 +403,7 @@ func (p *Package) IsCommand() bool { // ImportDir is like Import but processes the Go package found in // the named directory. func (ctxt *Context) ImportDir(dir string, mode ImportMode) (*Package, error) { - p, err := ctxt.Import(".", dir, mode) - if err == nil && !ctxt.isDir(p.Dir) { - err = fmt.Errorf("%q is not a directory", p.Dir) - } - return p, err + return ctxt.Import(".", dir, mode) } // NoGoError is the error used by Import to describe a directory diff --git a/src/go/build/build_test.go b/src/go/build/build_test.go index 6bade1d318..c9f906a7da 100644 --- a/src/go/build/build_test.go +++ b/src/go/build/build_test.go @@ -5,7 +5,6 @@ package build import ( - "fmt" "internal/testenv" "io" "os" @@ -346,13 +345,3 @@ func TestImportVendorParentFailure(t *testing.T) { t.Fatalf("error on failed import does not mention GOROOT/src/vendor directory:\n%s", e) } } - -// Issue 3248 -func TestBogusDirectory(t *testing.T) { - const dir = "/foo/bar/baz/gopher" - _, err := ImportDir(dir, FindOnly) - want := fmt.Sprintf("%q is not a directory", filepath.FromSlash(dir)) - if err == nil || err.Error() != want { - t.Errorf("got error %q, want %q", err, want) - } -} -- 2.48.1