douwanc63652 2018-01-20 20:47
浏览 286
已采纳

使用dep时强制特定版本的依赖项

I am using dep to manage the dependencies of a Go tool I'm writing.

This tool uses https://github.com/desertbit/grumble as an dependency. This in turn uses https://github.com/chzyer/readline as a dependency. The problem is that when trying to run my tool I get the following error: vendor/github.com/desertbit/grumble/app.go:295:20: unknown field 'HistorySearchFold' in struct literal of type readline.Config

I know why this is happending. grumble uses the master branch of readline as a dependency. In this the field HistorySearchFold is available. When using dep init/dep ensure not the master but the 1.4 tag is pulled into the vendor folder.

My question therefore is: How can I force dep to pull the master branch instead?

I tried adding the following in my Gopkg.toml file:

[[constraint]]
  branch = "master"
  name = "github.com/chzyer/readline"

Sadly this is not working. When I check the version pulled into the vendor folder it is still 1.4.

  • 写回答

1条回答 默认 最新

  • dpn4073 2018-01-21 07:52
    关注

    If you are trying to control the version of a transient dependency (not one directly used by your package, you should use the [[override]] directive

    It looks exactly the same as a constraint, but it will constrain dependencies even when not directly inherited by your package.

    [[override]]
      branch = "master"
      name = "github.com/chzyer/readline"
    

    Note that this is also useful for when the dependency solver finds conflicting dependencies, e.g. your package P makes use of packages A and B, and both depend on different versions of package X... you can use an override on package X inside of your package P

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

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧