- 首页 > it技术 > >
protobuf3|protobuf3 any用法
package mainimport (
"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 = https://www.it610.com/article/[]byte("ddd")
v["a"] = a
v["b"] = a
ws.Value = https://www.it610.com/article/vdd, _ := proto.Marshal(ws)ws2 := new(WebSocketMessage)
proto.Unmarshal(dd, ws2)
spew.Dump(ws2)
fmt.Printf(" %s", ws2.GetValue())
}
推荐阅读