Bazel-构建不参考外部依赖性
我正在尝试使用Bazel进行一些GRPC测试。 我正在使用“ google.golang.org/grpc/credentials/insecure”
来拨打不安全。
运行Bazel Test ...
时,我会收到以下错误:
no such package '@org_golang_google_grpc//credentials/insecure': BUILD file not found in directory 'credentials/insecure' of external repository @org_golang_google_grpc. Add a BUILD file to a directory to mark it as a package. and referenced by '//go/internal/handlers/helloworld:helloworld_test'
我正在用瞪羚生成构建文件,该文件将其输出以go_test
go_test(
name = "helloworld_test",
srcs = ["helloworld_test.go"],
deps = [
":helloworld",
"//protos/helloworld",
"@com_github_stretchr_testify//assert",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//test/bufconn",
"@org_uber_go_zap//:zap",
"@org_uber_go_zap//zaptest",
],
)
my go.mod文件包含dep: google.golang.org/grpc v1.47.0
我的deps.bzl是由瞪羚生成的:
go_repository(
name = "org_golang_google_grpc",
importpath = "google.golang.org/grpc",
sum = "h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8=",
version = "v1.47.0",
)
我缺少什么?
I'm trying to run some grpc tests with bazel.
I'm using "google.golang.org/grpc/credentials/insecure"
to dial insecurely.
When running bazel test ...
, I get the following error:
no such package '@org_golang_google_grpc//credentials/insecure': BUILD file not found in directory 'credentials/insecure' of external repository @org_golang_google_grpc. Add a BUILD file to a directory to mark it as a package. and referenced by '//go/internal/handlers/helloworld:helloworld_test'
I am generating my BUILD files with gazelle which outputs this for the go_test
go_test(
name = "helloworld_test",
srcs = ["helloworld_test.go"],
deps = [
":helloworld",
"//protos/helloworld",
"@com_github_stretchr_testify//assert",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//credentials/insecure",
"@org_golang_google_grpc//test/bufconn",
"@org_uber_go_zap//:zap",
"@org_uber_go_zap//zaptest",
],
)
My go.mod file contains the dep:google.golang.org/grpc v1.47.0
My deps.bzl is auto generated by gazelle:
go_repository(
name = "org_golang_google_grpc",
importpath = "google.golang.org/grpc",
sum = "h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8=",
version = "v1.47.0",
)
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在工作空间中,必须在gazelle_depentencies()之前调用瞪羚生成的本地go_repositories(),它将
定义一个古代版本的org_golang_google_grpc(如果不是)
存在,新版本的本地go_repository将是
默默地忽略。 参考
In the WORKSPACE, the local go_repositories() generated by gazelle must be called before gazelle_dependencies(), which will
define an ancient version of org_golang_google_grpc if it doesn't
exist yet and the local go_repository for the newer version will be
silently ignored. Reference