doutuoben6908 2019-04-06 09: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-07 03: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 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题