为什么无法定位我的供应商库?

huangapple go评论95阅读模式
英文:

Why doesn't go locate my vendored library?

问题

package vpc_app/unit_test.go:

import (
    "github.com/my-org/my-library/http"
)
...

package github.com/my-org/my-library/http/http.go:

package http
...

文件结构:

$ tree
.
├── glide.lock
├── glide.yaml
├── unit
│   └── modules
│       └── vpc
│           └── vpc-app
│               └── unit_test.go
└── vendor
    └── github.com
        └── my-org
            └── my-library
                ├── http
                │   └── http.go

问题:

当我运行 go test ./... 时,我得到以下错误:

vendor/github.com/my-org/my-library/url_checker.go:7:2: cannot find package "github.com/my-org/my-library/http" in any of:
    /usr/local/go/src/github.com/my-org/my-library/http (from $GOROOT)
    /Users/josh/go/src/github.com/my-org/my-library/http (from $GOPATH)

问题:

我正在使用 go 1.6,但它似乎没有查找我的 vendor 目录来找到该包。有任何关于这个问题的想法吗?

更新 #1:
根据您的要求,这是我的 go env 输出:

OARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/josh/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
英文:

package vpc_app/unit_test.go:

import (
	"github.com/my-org/my-library/http"
)
...

package github.com/my-org/my-library/http/http.go:

package http
...

File Structure:

$ tree
tree
.
├── glide.lock
├── glide.yaml
├── unit
│   └── modules
│       └── vpc
│           └── vpc-app
│               └── unit_test.go
└── vendor
    └── github.com
        └── my-org
            └── my-library
                ├── http
                │   └── http.go

Problem:

When I run go test ./... I get this error:

vendor/github.com/my-org/my-library/url_checker.go:7:2: cannot find package "github.com/my-org/my-library/http" in any of:
	/usr/local/go/src/github.com/my-org/my-library/http (from $GOROOT)
	/Users/josh/go/src/github.com/my-org/my-library/http (from $GOPATH)

Question:

I'm using go 1.6, but it doesn't seem to look in my vendor directory to find the package. Any ideas on why that might be?

Update #1:
As requested, here's my go env output:

OARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/josh/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

答案1

得分: 1

我的存储库没有位于GOPATH中。将其移动到$GOPATH/src/github.com/my-org/my-library解决了问题。

英文:

My repo wasn't located in the GOPATH. Moving it to $GOPATH/src/github.com/my-org/my-library did the trick.

答案2

得分: 0

那个错误来自于vendor/github.com/my-org/my-library/url_checker.go,它位于你的vendor文件夹中。

看起来它确实找到了vendor文件夹,但问题是由于vendor/github.com/my-org/my-library/url_checker.go中第7行的导入语句引起的。

正在调查是否存在与vendor文件夹的递归依赖关系有关的问题。

为了明确起见,你能提供go env的输出吗?

英文:

That error is originating from vendor/github.com/my-org/my-library/url_checker.go which is in your vendor folder.

It looks like it is finding the vendor folder, but the issue is due to an import statement in vendor/github.com/my-org/my-library/url_checker.go on line 7

Investigating to see if there is an issue with recursive dependencies with vendor folders.

Just to be clear can you provide the output of go env?

huangapple
  • 本文由 发表于 2016年4月2日 06:54:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/36367037.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定