我认为问题是您在命令行上传递给Gazelle的导入前缀(
github.com/BazelBuildForGo
)与中的进口不同。go文件(
github.com/wix-private/BazelBuildForGo
)。当Gazelle看到当前前缀之外的导入时,它将为这些导入生成外部依赖项,并且这些依赖项将丢失:
go_library(
name = "go_default_library",
srcs = ["p1lib.go"],
importpath = "github.com/BazelBuildForGo/project1/p1lib",
visibility = ["//visibility:public"],
deps = ["@com_github_wix_private_bazelbuildforgo//project1/dep1:go_default_library"],
)
不过,解决这个问题相当容易。只需运行带有前缀的Gazelle
github。com/wix private/BazelBuildForGo
。实际上你已经有这个了
//:gazelle
,所以只需运行它,然后重建。
$ bazel run //:gazelle
$ bazel build //...
这将改变
go_library
上述规则:
go_library(
name = "go_default_library",
srcs = ["p1lib.go"],
importpath = "github.com/wix-private/BazelBuildForGo/project1/p1lib",
visibility = ["//visibility:public"],
deps = ["//project1/dep1:go_default_library"],
)