gpt4 book ai didi

go - 扫描 github.com/golang/protobuf/proto/testdata : cannot find package "." 时出错

转载 作者:IT王子 更新时间:2023-10-29 02:09:46 26 4
gpt4 key购买 nike

在我的项目上运行 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,所以错误一定来 self 使用的依赖项之一。

在我的项目上运行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 并且在此之前从未失败过,我也没有最近添加了任何新的依赖项)。

最佳答案

在你自己之前PR (995) , 有 glide issue 968

It looks like it's caused by a repository's structure changing, i.e. a sub-package being moved, or removed entirely.

Elliot Wright (seeruk) 提出的变通办法:

If the package that has been updated is under your own control, then I've since found it easier to use some of the newer Go features like type aliases to ease the pain from refactoring.
So, instead of just moving a package, move it and then make aliases to the new location in the old one so that your older code still works.
Then, gradually move things over. Basically just mark things as deprecated but make sure they're still usable for a little while until you've ported new code over.

If the package is not in your control, then you can always clone the version you want manually to your vendor folder and make your updates in your code.
Once you're done, Glide should let you update again.
If it's much more complex, sometimes it's even easier to revert to using go get until you're done updating packages, and rely on your $GOPATH contents.

It's far from ideal, but there are ways you can work around it at least.
In the mean time, I've also made an issue about this on dep.
I think they're looking into a way of disabling this kind of check if you just want the tool to trust you as the developer.

所以您可以使用 godep 检查您是否有同样的问题,甚至是前沿vgo .

关于go - 扫描 github.com/golang/protobuf/proto/testdata : cannot find package "." 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50550127/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com