我使用的是MacOS 10.13.2操作系统。 Go版本是1.10。 Bazel版本是0.11.1。
我需要编译一个包含两个项目(project1和project2)的仓库。 project1有两个子包,即p1lib和dep1。 p1lib使用了dep1。
我使用gazelle生成BUILD文件,文件看起来没问题。
gazelle -go_prefix=github.com/BazelBuildForGo
但当我运行构建时,出现了一个错误,说我缺少直接依赖。
bazel build //project1
INFO: Analysed target //project1:project1 (3 packages loaded).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_user1/df78026a5ee0c7ed3d23dd05c3a3b1f7/external/com_github_wix_private_bazelbuildforgo/project1/p1lib/BUILD.bazel:3:1: GoCompile external/com_github_wix_private_bazelbuildforgo/project1/p1lib/darwin_amd64_stripped/go_default_library~/github.com/BazelBuildForGo/project1/p1lib.a failed (Exit 1)
2018/03/25 18:02:55 missing strict dependencies:
external/com_github_wix_private_bazelbuildforgo/project1/p1lib/p1lib.go: import of github.com/wix-private/BazelBuildForGo/project1/dep1, which is not a direct dependency
Target //project1:project1 failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.358s, Critical Path: 0.12s
FAILED: Build did NOT complete successfully
我的项目可以在这里找到:https://github.com/wix-playground/BazelBuildForGo