Protobuf Go
约 1 分钟阅读
标签:Go语言
- protocolbuffers/protobuf-goGitHubprotocolbuffers/protobuf-goprotocolbuffers/protobuf-go · 2020-03-02 A new Go API for Protocol Buffers · APIv1 github.com/golang/protobuf · github.com/golang/[email protected] 使用 APIv2 实现笔记:Protobuf Go
- 2020-03-02 A new Go API for Protocol Buffers
- APIv1 github.com/golang/protobuf
- github.com/golang/[email protected] 使用 APIv2 实现
- APIv2 google.golang.org/protobuf
- google.golang.org/[email protected] 依赖 github.com/golang/[email protected]
- 动态 pb
- APIv1 github.com/golang/protobuf
APIv2
- v2 protoreflect.ProtoMessage
- v1 protoiface.MessageV1
// 基于反射的主要接口
type ProtoMessage interface{ ProtoReflect() Message }
// v2
// 反射信息
type Message interface {
Descriptor() MessageDescriptor
Type() MessageType
New() Message
Interface() ProtoMessage
Range(f func(FieldDescriptor, Value) bool)
Has(FieldDescriptor) bool
Clear(FieldDescriptor)
Get(FieldDescriptor) Value
Set(FieldDescriptor, Value)
Mutable(FieldDescriptor) Value
NewField(FieldDescriptor) Value
WhichOneof(OneofDescriptor) FieldDescriptor
GetUnknown() RawFields
SetUnknown(RawFields)
IsValid() bool
ProtoMethods() *methods
}
// v1
type MessageV1 interface {
Reset()
String() string
ProtoMessage()
}proto
- golang proto v2 基于反射
- github.com/golang/protobuf/proto
- 反射
- 全局注册 - google.golang.org/protobuf/reflect/protoregistry
- GlobalFiles
- GlobalTypes
- 全局注册 - google.golang.org/protobuf/reflect/protoregistry
关联信息
反向链接和本文引用的外部资料。
反向链接
- protobuf笔记 · Go
protocolbuffers/protobuf · Protocol Buffers - Google's data interchange format · 包含实现: C++, Java, Python, Objective-C, C#, Ruby, PHP
References
GitHub
1 条- protocolbuffers/protobuf-gogithub.com/protocolbuffers/protobuf-go
其他外链
1 条- go.dev/blog/protobuf-apiv2go.dev/blog/protobuf-apiv2