Bazel-构建不参考外部依赖性

发布于 2025-02-08 16:22:06 字数 1287 浏览 2 评论 0原文

我正在尝试使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见终念 2025-02-15 16:22:06

在工作空间中,必须在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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文