glide踩坑记

glide 我就不做过多介绍了,它是golang的包管理工具之一,由于该工具github上面不在维护,官方也推荐使用dep,所以之前也使用过dep,但是由于 dep 一直拉取不了 golang.org/x 相关依赖,无奈只能又切回 glide。

坑位

  1. 拉取 golang.org/x 相关包同样失败,报 Cannot detect VCS

    • 解决方案

      1
      2
      3
      4
      5
      6
      7
      8
      // 替换拉取镜像
      glide mirror set https://golang.org/x/mobile https://github.com/golang/mobile --vcs git
      glide mirror set https://golang.org/x/crypto https://github.com/golang/crypto --vcs git
      glide mirror set https://golang.org/x/net https://github.com/golang/net --vcs git
      glide mirror set https://golang.org/x/tools https://github.com/golang/tools --vcs git
      glide mirror set https://golang.org/x/text https://github.com/golang/text --vcs git
      glide mirror set https://golang.org/x/image https://github.com/golang/image --vcs git
      glide mirror set https://golang.org/x/sys https://github.com/golang/sys --vcs git
  2. 私库的包拉取不了

    • 解决方案

      1
      2
      // 同样替换拉取镜像
      glide mirror set [本地代码中import的包名,例如:test/keng] [对应私库的地址(http://host/test/keng] --vcs git
  3. 无法拉取子包

    假设你要拉取的包在glide.yaml中配置如下:

    1
    - package: golang.org/x/net/context

    此时同样会报 Cannot detect VCS,因为不支持拉取子包

    • 解决方案

      修改glide.yaml中的配置如下:

      1
      2
      3
      - package: golang.org/x/net
      subpackages:
      - context
小伙伴,如果您觉得文章还不错,欢迎您的支持,我会继续努力创作!