duanjue7745 2017-06-28 12:39
浏览 123

如何使用本地版本的glide依赖项?

I'm working on a Go project that uses Glide for dependency management. I need to make changes to the project, but also to several dependencies used by the project. I need to test these changes together, before committing the alterations to each project separately.

How can I tell Glide (or Go) to use local versions of these projects (e.g. found in $GOPATH/src/...) rather than pulling down something and stuffing it in the vendor directory)?

To give an example:

  • github.com/hyperledger/burrow depends on:
  • github.com/tendermint/tendermint, which depends on:
  • github.com/tendermint/go-crypto

I need to make some changes spanning all three projects. I want to test the changes by executing things in the burrow project, but I need it to execute my development versions of tendermint and go-crypto, which I have locally.

  • 写回答

2条回答 默认 最新

  • douzhang8840 2017-06-28 12:50
    关注

    If you want to test the dependencies under '$GOPATH/src/...' just temporally remove every glide file in the root of your project (glide.yaml, glide.lock,etc...). Then you can put back those files if you need to use 'vendor' dependencies again.

    Update 1

    I was looking for the same solution for my projects then I figured out that glide documentation specifies an extra useful parameter on glide.yaml for imports. According to the official documentation:

    repo: If the package name isn't the repo location or this is a private repository it can go here. The package will be checked out from the repo and put where the package name specifies. This allows using forks.

    In that case you just push your code somewhere (GitHub or Gitlab for private repos of your $GOPATH/src/github.com/hyperledger/burrow I guess) then edit your glide.yaml:

    - package: github.com/tendermint/tendermint <-- vendor name dependencies
      repo:    github.com/myrepo/tendermint   <-- your remote fork
      version: vx.x.x or your sha commit code
    

    In this way you can switch from your official version to your fork and make your tests. To turn back to your official version just remove or comment repo and version attributes:

    - package: github.com/tendermint/tendermint <-- vendor name dependencies
    #  repo:    github.com/myrepo/tendermint   <-- your remote fork
    #  version: vx.x.x or your sha commit code
    

    I'm testing my forks in this way now and you don't need to change your import paths into your code, hope this helps.

    Update 2

    Another useful way is to use glide mirror:

    Mirrors provide the ability to replace a repo location with another location that's a mirror of the original. This is useful when you want to have a cache for your continuous integration (CI) system or if you want to work on a dependency in a local location.

    I guess this one is the best solution, for example, on command line type:

    $ glide mirror set github.com/tendermint/tendermint file:///User/yourname/Gospace/src/github.com/tendermint/tendermint
    

    This will create a mirror.yaml in your GLIDE_HOME (if not exists then will be placed under your $USER/.glide folder). Now you can test your local version (under GOPATH) without fork your project (as I wrote above). Once you finished your tests just remove it:

    $ glide mirror remove github.com/tendermint/tendermint
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器