如何获取并构建没有主要功能的go包的所有依赖项?

时间:2018-08-07 19:23:41

标签: go

我有一个以下项目:

myrepo/     # root package, no main() function
  |-common/ # common utilties package
  |-cmd/    # CLI root
  |   |-myrepo-a/   # CLI application A
  |   |   |-main.go # CLI application A main package/function, 
  |   |             # setting up feature A for CLI use
  |   |-myrepo-b/   # CLI application B
  |       |-main.go # CLI application B main package/function,
  |                 # setting up feature B for CLI use
  |-aspecific/  # package with generic implementation for feature A
  |-bspecific/  # package with generic implementation for feature B
  |-generate.go # file dispatching //go:generate instructions

如何获取和构建此类myrepo项目的依赖项?

go get -v ./...调用会产生错误:

runtime.main_main·f: relocation target main.main not defined
runtime.main_main·f: undefined: "main.main"

我可以避免手动为go get ./common/... ./cmd/... ./aspecific/... ./bspecific/...中的调用指定每个子包,因为这样的硬编码可能会导致实际项目状态与要构建的包之间的不同步?

0 个答案:

没有答案