在我的项目上运行glide install
时,我会得到以下错误:
[ERROR] Error scanning github.com/golang/protobuf/proto/testdata: cannot find package "." in:
/Users/bevernie/.glide/cache/src/https-github.com-golang-protobuf/proto/testdata
[ERROR] Failed to retrieve a list of dependencies: Error resolving imports
在检查protobuf的源代码时,我实际上可以看到没有这样的包。但是,我不直接使用protobuf,因此错误必须来自我使用的依赖项之一。
在我的项目上运行glide tree
时,只有一个github.com/golang/protobuf/proto/testdata
实例
|-- github.com/golang/protobuf/proto (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/proto)
| |-- github.com/golang/protobuf/proto/test_proto (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/proto/test_proto)
| | |-- (Recursion) github.com/golang/protobuf/proto (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/proto)
| |-- github.com/golang/protobuf/ptypes/any (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/ptypes/any)
| | |-- (Recursion) github.com/golang/protobuf/proto (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/proto)
github.com/golang/protobuf/proto/testdata (glide get github.com/golang/protobuf/proto/testdata)
|-- github.com/golang/protobuf/ptypes/any (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/ptypes/any)
| |-- github.com/golang/protobuf/proto (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/proto)
| | |-- github.com/golang/protobuf/proto/test_proto (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/proto/test_proto)
| | | |-- (Recursion) github.com/golang/protobuf/proto (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/proto)
| | |-- (Recursion) github.com/golang/protobuf/ptypes/any (/Users/bevernie/Programmation/work/src/github.com/golang/protobuf/ptypes/any)
这并不能真正帮助我找出问题的根源。
对于如何解决这些问题,你有什么建议吗?
直到一两周前,我的项目才进行了很好的编译(我使用Docker在生产中进行部署,因此glide install
每次都运行,在此之前从未失败过,最近我也没有添加任何新的依赖项)。
发布于 2018-05-27 08:33:00
看起来它是由存储库的结构变化引起的,即一个子包正在被移动,或者被完全删除。
)提出的解决办法
如果已经更新的包在您自己的控制之下,那么我发现使用一些较新的Go特性(比如类型别名)来减轻重构带来的痛苦会更容易。 所以,不要仅仅移动一个包,而是移动它,然后在旧包中的新位置创建别名,这样您的旧代码仍然可以工作。 然后,慢慢地把东西移开。基本上,只需将其标记为已不再推荐的内容,但要确保它们在一段时间内仍然可用,直到您移植完新代码。 如果包不在您的控制范围内,则始终可以将您想要的版本手动克隆到您的供应商文件夹中,并在代码中进行更新。 一旦你完成了,幻灯片应该让你再次更新。 如果它要复杂得多,有时甚至更容易恢复到使用
go get
,直到您完成更新包,并依赖您的$GOPATH
内容。 这远非理想,但至少有一些方法可以绕过它。 同时,我也在dep上对此提出了一个问题。 我认为他们正在研究一种禁用这种检查的方法,如果您只想让工具信任您作为开发人员。
https://stackoverflow.com/questions/50550127
复制相似问题