为了账号安全,请及时绑定邮箱和手机立即绑定

我需要先从本地使用我的库 golang 来测试更改

我需要先从本地使用我的库 golang 来测试更改

Go
蝴蝶刀刀 2022-06-27 15:00:51
我在我的库 golang 中进行了本地更改,在推送到 github 存储库之前我必须先测试这些更改,我的想法是从另一个服务模块进行测试并调用库来使用这些方法。我能做到这一点吗?
查看完整描述

2 回答

?
幕布斯6054654

TA贡献1876条经验 获得超7个赞

响应令人困惑,为了澄清这一点,我希望更好地记录我的解决方案:


在 go.mod 文件中,我必须使用本地开发而不是存储库 github.com/../../..


我们有一个步骤,简单地说,写替换 <github.com/repository> => myLocalFolder


例子:


//go.mod

require (

    //this is a repository that I want change

    github.com/example/my-reposiory v1.2.0

    

)

//这里写replace,实现使用本地代码代替仓库代码


replace github.com/avaldigitallabs/adl-habilitadora-lib-go-shared-kernel => /Users/<my_user>/Documents/Projects/my_local_folder

//go.mod 完整示例:


module my-module


go 1.14


require (

    github.com/example/my-reposiory v1.2.0

)


replace github.com/example/my-reposiory => /Users/<my_user>/Documents/Projects/my_local_folder



查看完整回答
反对 回复 2022-06-27
?
慕标琳琳

TA贡献1830条经验 获得超9个赞

我能做到这一点吗?

是的当然。去做就对了。replacego.mod 中的指令可能会对您有所帮助。


查看完整回答
反对 回复 2022-06-27
  • 2 回答
  • 0 关注
  • 111 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号