有没有一种方法可以像 encoding/json 为 custom marshal/unmarshal json 提供方法一样自定义 marshal/unmarshal protobuf?在戈朗?
最佳答案
更新:
proto3 go 库 ( https://google.golang.org/protobuf/proto ) 不再支持自定义编码。
弃用:
GoDoc 提到 Marshaler和 Unmarshaler接口(interface)。
type Marshaler interface {
Marshal() ([]byte, error)
}
type Unmarshaler interface {
Unmarshal([]byte) error
}
关于go - 有没有办法在 golang 中自定义 Marshaling Protobuf?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41606157/