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

我在我的库 golang 中进行了本地更改,在推送到 github 存储库之前我必须先测试这些更改,我的想法是从另一个服务模块进行测试并调用库来使用这些方法。我能做到这一点吗?



蝴蝶刀刀
浏览 113回答 2
2回答

幕布斯6054654

响应令人困惑,为了澄清这一点,我希望更好地记录我的解决方案:在 go.mod 文件中,我必须使用本地开发而不是存储库 github.com/../../..我们有一个步骤,简单地说,写替换 <github.com/repository> => myLocalFolder例子://go.modrequire (&nbsp; &nbsp; //this is a repository that I want change&nbsp; &nbsp; github.com/example/my-reposiory v1.2.0&nbsp; &nbsp;&nbsp;)//这里写replace,实现使用本地代码代替仓库代码replace github.com/avaldigitallabs/adl-habilitadora-lib-go-shared-kernel => /Users/<my_user>/Documents/Projects/my_local_folder//go.mod 完整示例:module my-modulego 1.14require (&nbsp; &nbsp; github.com/example/my-reposiory v1.2.0)replace github.com/example/my-reposiory => /Users/<my_user>/Documents/Projects/my_local_folder

慕标琳琳

我能做到这一点吗?是的当然。去做就对了。replacego.mod 中的指令可能会对您有所帮助。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go