douyue7408 2018-05-27 07:53
浏览 1257
已采纳

扫描github.com/golang/protobuf/proto/testdata时出错:找不到包“。”

When running glide install on my project, I get the following error:

[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

When checking protobuf's source code, I can in fact see that there is no such package. I however don't directly use protobuf, so the error must come from one of the dependencies I use.

When running glide tree on my project, there is only one instance of 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)

which doesn't really help me pinpoint the source of the problem.

Do you have any suggestions as of how to fix the issues?

My project was compiling just fine until a week or two ago (I use Docker to deploy in production, so the glide install was run every time and never failed before that, and I haven't added any new dependency recently).

  • 写回答

1条回答 默认 最新

  • doushen9863 2018-05-27 08:33
    关注

    Before your own PR (995), there was 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.

    Workarounds proposed by 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.

    So you can check if you have the same issue using godep, or even the bleeding-edge vgo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格