protocol-buffers - Protocol Buffers Version 2 中的 "import weak"是什么意思?

标签 protocol-buffers

Import Statement在 Protocol Buffers Version 2 Language Specification 中有以下文本:

import = "import" [ "weak" | “public”] strLit ";" 

但是Importing Definitions在 Protocol Buffers Version 2 Language Guide 中只谈到了 public 的使用。 import weak 是什么意思?我用谷歌搜索了答案。但我找不到解释。

最佳答案

弱导入是可选的依赖。

请参阅 EnforceWeakDependencies 的文档一些细节:

void DescriptorPool::EnforceWeakDependencies(
        bool enforce)

By default, weak imports are allowed to be missing, in which case we will use a placeholder for the dependency and convert the field to be an Empty message field.

If you call EnforceWeakDependencies(true), however, the DescriptorPool will report a import not found error.

关于protocol-buffers - Protocol Buffers Version 2 中的 "import weak"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33933397/

相关文章:

protocol-buffers - Google Protobuf 服务中的 RPC

android - 协议(protocol)设计

python - 如何将嵌套的 Protobuf 结构解析为 Python 字典?

go - 使用 gRPC 的上下文与 SendMsg/RecvMsg 方法发送元数据

c# - protobuf-net从.proto文件到.cs文件时是否支持字典? (通过 protogen.exe)

Python protobuf gRPC 生成一个不存在的依赖

go - 如何在Golang中将从protobuf导入的消息初始化为数组

java - 在 java Protocol Buffer 中导入 "google/protobuf/descriptor.proto"

c# - 二进制对象图序列化

java - Java Protocol Buffers 能否在重复字段的列表 getter 上返回 null?