go - 如何在 *.proto 文件中定义空接口(interface)?

标签 go protocol-buffers

我在 Go 中需要这样的结构:

type SomeStruct struct{
    Foo bool
    Bar interface{}
}

如何在*.proto文件中定义空接口(interface)?如果这不可能,那么如何解决变量类型 *.proto 文件字段的描述问题?

最佳答案

Protobuf 不支持泛型类型。 因为我知道所有可能的类型,所以我可以使用 Oneof :Oneof

关于go - 如何在 *.proto 文件中定义空接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55672809/

相关文章:

mongodb - 去 + MongoDB : polymorphic queries

python - 如何获取python3中protobuf的RepeatedCompositeContainer或RepeatedScalarContainer包含的类型?

c++ - 谷歌 Protocol Buffer 。 C++ 错误 : 'protobuf' does not name a type

multithreading - 为什么我的 goroutines 在完成时互相等待而不是完成?

json - 在go lang中循环/迭代第二级嵌套JSON

http - 使用 HTTP/1.0 的 Golang HTTP POST

xml - Golang : No response from get. http( 网址 )

c# - 针对空间优化的序列化库?

c# - 如何使用 protobuf 将 ServiceStack 服务与非 ServiceStack 客户端集成?

c# - 使用 protobuf-net 发布反序列化 (protocolBuffer) 序列化数据