MCPcopy Create free account
hub / github.com/cloudwego/dynamicgo / ExampleBinaryProtocol_ReadAnyWithDesc

Function ExampleBinaryProtocol_ReadAnyWithDesc

thrift/example_test.go:92–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

90}
91
92func ExampleBinaryProtocol_ReadAnyWithDesc() {
93 p1, err := NewDescritorFromPath(context.Background(), "../testdata/idl/example2.thrift")
94 if err != nil {
95 panic(err)
96 }
97 example2ReqDesc := p1.Functions()["ExampleMethod"].Request().Struct().FieldById(1).Type()
98 data, err := ioutil.ReadFile("../testdata/data/example2.bin")
99 if err != nil {
100 panic(err)
101 }
102
103 p := NewBinaryProtocol(data)
104 v, err := p.ReadAnyWithDesc(example2ReqDesc, false, false, false, true)
105 if err != nil {
106 panic(err)
107 }
108 fmt.Printf("%#v", v)
109 p = NewBinaryProtocolBuffer()
110 err = p.WriteAnyWithDesc(example2ReqDesc, v, true, true, true)
111 if err != nil {
112 panic(err)
113 }
114 fmt.Printf("%x", p.RawBuf())
115}

Callers

nothing calls this directly

Calls 11

ReadAnyWithDescMethod · 0.95
WriteAnyWithDescMethod · 0.95
RawBufMethod · 0.95
NewBinaryProtocolFunction · 0.85
FieldByIdMethod · 0.80
StructMethod · 0.80
FunctionsMethod · 0.80
NewDescritorFromPathFunction · 0.70
NewBinaryProtocolBufferFunction · 0.70
RequestMethod · 0.65
TypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…