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, 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 {