From 233cb1f7b5608103ac96a6c1c20bcee2dabd9d45 Mon Sep 17 00:00:00 2001 From: Francesc Campoy Date: Fri, 10 Mar 2017 10:36:09 -0800 Subject: [PATCH 1/2] Support vendor directory as $GOPATH/src/vendor Updates #148 --- context.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/context.go b/context.go index a5c893aa4d..a06e018f43 100644 --- a/context.go +++ b/context.go @@ -124,6 +124,11 @@ func (c *Ctx) LoadProject(path string) (*Project, error) { // // The second returned string indicates which GOPATH value was used. func (c *Ctx) SplitAbsoluteProjectRoot(path string) (string, error) { + // allow vendor directory to be directly under GOPATH/src + if filepath.Join(c.GOPATH, "src") == path { + return ".", nil + } + srcprefix := filepath.Join(c.GOPATH, "src") + string(filepath.Separator) if filepath.HasPrefix(path, srcprefix) { // filepath.ToSlash because we're dealing with an import path now, From 52155e3b93c0e7002f6babbadc0dea5234f49288 Mon Sep 17 00:00:00 2001 From: Francesc Campoy Date: Sat, 11 Mar 2017 17:31:49 -0800 Subject: [PATCH 2/2] add test for /Users/campoy/src/vendor --- context_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/context_test.go b/context_test.go index e71c0a879d..a9e60c264e 100644 --- a/context_test.go +++ b/context_test.go @@ -57,6 +57,13 @@ func TestSplitAbsoluteProjectRoot(t *testing.T) { } } + // test when the full path corresponds to $GOPATH/src + if got, err := depCtx.SplitAbsoluteProjectRoot(filepath.Join(depCtx.GOPATH, "src")); err != nil { + t.Fatal(err) + } else if got != "." { + t.Fatalf("expected ., got %s", got) + } + // test where it should return error got, err := depCtx.SplitAbsoluteProjectRoot("tra/la/la/la") if err == nil {