go - 在 monorepo 环境中发布 go 模块

标签 go go-modules

假设我有一个 monorepo,并且有几个单独的 golang 服务:

root    
└── services
        ├── svc1
        │   ├── go.mod
        │   ├── go.sum
        │   └── main.go
        └── svc2
            ├── go.mod
            ├── go.sum
            └── main.go
而 svc2 将来会依赖于 svc1。此外,要求 svc1 和 svc2 可以单独发布。
有没有办法可以单独发布模块? go mod 文档只假设只有 repo,所以它不提供这种灵 active 。

最佳答案

要在存储库的子目录中标记模块的发布版本,请将子目录添加为标记的前缀,例如 svc1/v0.1.0 .
根据 https://golang.org/ref/mod#vcs-version :

If a module is defined in a subdirectory within the repository …, then each tag name must be prefixed with the module subdirectory, followed by a slash. For example, the module golang.org/x/tools/gopls is defined in the gopls subdirectory of the repository with root path golang.org/x/tools. The version v0.4.0 of that module must have the tag named gopls/v0.4.0 in that repository.

关于go - 在 monorepo 环境中发布 go 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67224249/

相关文章:

regex - 使用正则表达式验证密码

xml - 获取原始元素表示,包括开始和结束标签

Golang 模块问题--package xxx/xxxx is not in GOROOT

go get -u github.com/onsi/ginkgo/ginkgo 突然开始抛出错误

sql - Gorm Ping Db碎片

assembly - 如何在golang中使用汇编代码中定义的函数?

templates - 获取当前模板名称?

go - 使用 go.mod 灵活部署到 google app engine 失败,因为它正在 GOPATH 中寻找依赖库

go - 开发多模块 Go 工作区的问题

go - 构建期间的模块依赖缓存问题