如何使用协议缓冲区编组 *big.Int?

时间:2021-02-07 23:41:29

标签: go protocol-buffers

我想在 Go 中使用 *big.Int 创建一个协议缓冲区消息。最好的方法是什么?

1 个答案:

答案 0 :(得分:1)

big.Int 实现 encoding.TextMarshalerhttps://golang.org/pkg/math/big/#Int.MarshalText

...,您可以轻松地将 []byte 序列化为 protobuf。