Night1008Night1008
返回文章列表
•约 141 字•预计阅读 1 分钟•Issue #12•

Go mod 如何替换 fork 的包和版本

以 github.com/prashanthpai/sqlcache 为例,想替换成 fork 的包 github.com/night1008/sqlcache,
假设当前该包的版本为 v0.0.0

第一步

go mod edit -replace github.com/prashanthpai/sqlcache@v0.0.0=github.com/night1008/sqlcache@master

第二步

go get -u github.com/night1008/sqlcache

会有以下提示

go: downloading github.com/night1008/sqlcache v0.0.0-20240623031410-4d47c940a2d7
go: github.com/night1008/sqlcache@v0.0.0-20240623031410-4d47c940a2d7: parsing go.mod:
	module declares its path as: github.com/prashanthpai/sqlcache
	        but was required as: github.com/night1008/sqlcache

第三步

手动把 v0.0.0-20240623031410-4d47c940a2d7 替换到 go.mod replace github.com/prashanthpai/sqlcache v0.0.0 => github.com/night1008/sqlcache master 这一行的 master


第四步

go mod tidy
本文由 GitHub Issue #12 同步驱动
在 GitHub 上编辑/讨论

评论互动