我看到以下错误:
link: package conflict error: google.golang.org/genproto/googleapis/api/annotations: multiple copies of package passed to linker:
@go_googleapis//google/api:annotations_go_proto
@org_golang_google_genproto//googleapis/api/annotations:annotations
Set "importmap" to different paths or use 'bazel cquery' to ensure only one
package with this path is linked.
@org_golang_google_genproto//googleapis/api/annotations:annotations
通过:
@com_github_uber_cadence//service/history:go_default_library
@com_github_uber_cadence//service/history:history
@com_github_uber_cadence//common/resource:resource
@com_github_uber_cadence//common/archiver/provider:provider
@com_github_uber_cadence//common/archiver/gcloud:gcloud
@com_github_uber_cadence//common/archiver/gcloud/connector:connector
@com_google_cloud_go_storage//:storage
@org_golang_google_genproto//googleapis/iam/v1:iam
@org_golang_google_genproto//googleapis/api/annotations:annotations
@org_golang_google_genproto//googleapis/api/annotations:annotations
可以被@go_googleapis//google/api:annotations_go_proto
禁用或遮蔽吗?如果有,怎么做?
选项一:
通过在repositories.bzl
文件中使用适当的gazelle:resolve
指令来更改使用@org_golang_google_genproto//googleapis/api/annotations
的@go_googleapis//google/api:annotations_go_proto
:
go_repository(
name = "com_google_cloud_go",
build_directives = [
# @go_googleapis is the modern version of @org_golang_google_genproto
# use @go_googleapis to avoid dependency conflicts between the two
"gazelle:resolve go google.golang.org/genproto/googleapis/iam/v1 @go_googleapis//google/iam/v1:iam_go_proto", # keep
],
…
)
go_repository(
name = "com_google_cloud_go_storage",
build_directives = [
# @go_googleapis is the modern version of @org_golang_google_genproto
# use @go_googleapis to avoid dependency conflicts between the two
"gazelle:resolve go google.golang.org/genproto/googleapis/iam/v1 @go_googleapis//google/iam/v1:iam_go_proto", # keep
"gazelle:resolve go google.golang.org/genproto/googleapis/type/expr @go_googleapis//google/type:expr_go_proto", # keep
"gazelle:resolve go google.golang.org/genproto/googleapis/api/annotations @go_googleapis//google/api:annotations_go_proto", # keep
],
…
)
下面也可以,但我更喜欢上面的,因为它使用了较新的库:
通过在根BUILD
文件中使用适当的gazelle:resolve
指令来更改使用@go_googleapis//google/api:annotations_go_proto
的@org_golang_google_genproto//googleapis/api/annotations
:
# gazelle:resolve go google.golang.org/genproto/googleapis/api/annotations @org_golang_google_genproto//googleapis/api/annotations
我考虑过的其他选择和我没有选择的原因:
- 升级到最新的
@com_google_cloud_go_storage
。没有选择这个选项,因为最新版本(v1.24.0
在这篇文章的时候)仍然使用@org_golang_google_genproto
。 - 升级
@com_google_cloud_go_storage
以使用@go_googleapis
。没有选择这个选项,因为它看起来太难合并了。 repo_mapping = {"@org_golang_google_genproto" : "@go_googleapis"}
forcom_google_cloud_go_storage
。没有选择这个选项,因为@go_googleapis
不是@org_golang_google_genproto
的直接替代品(@go_googleapis
使用前缀google
,而@org_golang_google_genproto
使用前缀googleapis
)。"gazelle:exclude **/common/archiver/gcloud/**"
forcom_github_uber_cadence
。没有选择这个选项,因为common/archiver/provider
依赖common/archiver/gcloud
。- 将
go_googleapis
的字冠从google
设置为googleapis
。我没有选择这个选项,因为它打破了那些熟悉go_googleapis
标准实践的人的期望。