如何添加自动生成的 go 依赖项?
我有一个 protobuf 存储库,其根目录中有一个 go-file,其中包含以下内容:
//go:generate ./scripts/generate_go_sources.sh
package protobuf
上述脚本遍历.proto
“message/”子文件夹中的所有文件,并生成 go-sources。
之后,存储库包含很多子包,如
ptyes/package1/file.go
ptyes/package2/file.go
我不想将这些文件签入版本控制。
如何使用 go dep 使用这个存储库?
我正在尝试切换到 go dep 进行依赖管理,但我无法说服它下载此存储库并执行“go generate”。
Solving failure: No versions of github.com/company/protobuf met constraints:
master: Could not introduce github.com/company/protobuf@master, as it is not allowed by constraint vendoring from project github.com/company/myProject.
develop: Could not introduce github.com/company/protobuf@develop, as it is not allowed by constraint vendoring from project github.com/company/myProject.
vendoring: Could not introduce github.com/company/protobuf@vendoring due to multiple problematic subpackages:
Subpackage github.com/company/protobuf/ptypes/package1 is missing. (Package is required by (root).)
Subpackage github.com/company/protobuf/ptypes/package2 is missing. Package is required by: (root)
go dep 发现了正确的存储库(供应商分支),但由于找不到所需的子包而将其丢弃。它们仅在根包中调用“go generate”后才出现。