doutuoben6908 2019-04-06 01:15
浏览 24
已采纳

与修改后的供应商一起使用模块和依赖项

I am trying to convert one Go project to the new modules standard, but I am having trouble with one dependency.

That repository has vendored a library (in this case golang.org/x/net/html) to add some functionality to the library; meaning that it has modified the vendored dependency (added a method to a struct).

So the problem is that after doing go mod init, when i execute go get ./... the system complains about a call to that added functionality, because it ignores the modified vendor and tries to import the upstream library instead.

Is there any way to let go mod know that it should use the vendored dependency?

  • 写回答

1条回答 默认 最新

  • dozr162106 2019-04-06 19:30
    关注

    You can try replace directive. Something along the lines of

    First

    cd ./vendor/golang.org/x/net/html
    go mod init
    

    Then in your root go.mod

    module your/super/module
    
    replace golang.org/x/net/html => ./vendor/golang.org/x/net/html
    
    require golang.org/x/net/html v0.0.0
    
    

    Note that both require and replace are required.

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

报告相同问题?

悬赏问题

  • ¥15 fluent设置了自动保存后,会有几个时间点不保存
  • ¥20 激光照射到四象线探测器,通过液晶屏显示X、Y值
  • ¥15 这怎么做,怎么在我的思路下改下我这写的不对
  • ¥50 数据库开发问题求解答
  • ¥15 安装anaconda时报错
  • ¥20 如何用Python处理单元格内连续出现的重复词语?
  • ¥15 小程序有个导出到插件方式,我是在分包下引入的插件,这个export的路径对吗,我看官方文档上写的是相对路径
  • ¥20 希望有人能帮我完成这个设计( *ˊᵕˋ)
  • ¥100 将Intptr传入SetHdevmode()将Intptr传入后转换为DEVMODE的值与外部代码不一致
  • ¥50 基于ERA5数据计算VPD