为了账号安全,请及时绑定邮箱和手机立即绑定

Bazel - BUILD 不引用外部依赖

Bazel - BUILD 不引用外部依赖

Go
泛舟湖上清波郎朗 2022-12-26 10:21:44
我正在尝试使用 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'我正在用 gazelle 生成我的 BUILD 文件,它为 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",    ],)我的 go.mod 文件包含 dep: google.golang.org/grpc v1.47.0我的 deps.bzl 是由 gazelle 自动生成的:go_repository(    name = "org_golang_google_grpc",    importpath = "google.golang.org/grpc",    sum = "h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8=",    version = "v1.47.0",)我错过了什么?
查看完整描述

1 回答

?
猛跑小猪

TA贡献1858条经验 获得超8个赞

在 WORKSPACE 中,gazelle 生成的本地 go_repositories() 必须在 gazelle_dependencies() 之前调用,如果它不存在,它将定义一个古老版本的 org_golang_google_grpc,而新版本的本地 go_repository 将被静默忽略。参考


查看完整回答
反对 回复 2022-12-26
  • 1 回答
  • 0 关注
  • 244 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号