我在我的库 golang 中进行了本地更改,在推送到 github 存储库之前我必须先测试这些更改,我的想法是从另一个服务模块进行测试并调用库来使用这些方法。我能做到这一点吗?
最佳答案
响应令人困惑,为了澄清这一点,我希望更好地记录我的解决方案:
在 go.mod 文件中,我必须使用本地开发而不是存储库 github.com/../../..
我们有一个步骤,简单地说,写替换
例子:
//这里写replace,实现使用本地代码代替仓库代码//go.mod
require (
//this is a repository that I want change
github.com/example/my-reposiory v1.2.0
)
//go.mod 完整示例:replace github.com/avaldigitallabs/adl-habilitadora-lib-go-shared-kernel => /Users/<my_user>/Documents/Projects/my_local_folder
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
关于go - 我需要先从本地使用我的库 golang 来测试更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63624020/