假设我有一个 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 thegopls
subdirectory of the repository with root pathgolang.org/x/tools
. The versionv0.4.0
of that module must have the tag namedgopls/v0.4.0
in that repository.
关于go - 在 monorepo 环境中发布 go 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67224249/