protobuf3 any用法
作者:
站长_郭生 | 来源:发表于
2018-08-17 10:19 被阅读0次package main
import (
"github.com/golang/protobuf/ptypes/any"
"github.com/gogo/protobuf/proto"
"github.com/davecgh/go-spew/spew"
"fmt"
)
func main() {
ws := new(WebSocketMessage)
v := make(map[string]*any.Any)
a := new(any.Any)
a.Value = []byte("ddd")
v["a"] = a
v["b"] = a
ws.Value = v
dd, _ := proto.Marshal(ws)
ws2 := new(WebSocketMessage)
proto.Unmarshal(dd, ws2)
spew.Dump(ws2)
fmt.Printf(" %s", ws2.GetValue())
}
本文标题:protobuf3 any用法
本文链接:https://www.haomeiwen.com/subject/qklzbftx.html
网友评论