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

Function ExampleBinaryConv_Do

conv/j2p/example_test.go:15–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13var opts = conv.Options{}
14
15func ExampleBinaryConv_Do() {
16 // get descriptor and data
17 desc := getExampleDesc()
18 data := getExampleData()
19
20 // make BinaryConv
21 cv := NewBinaryConv(opts)
22
23 // do conversion
24 out, err := cv.Do(context.Background(), desc, data)
25 if err != nil {
26 panic(err)
27 }
28
29 // validate result
30 exp := &example2.ExampleReq{}
31 err = json.Unmarshal(data, exp)
32 if err != nil {
33 panic(err)
34 }
35 act := &example2.ExampleReq{}
36 err = proto.Unmarshal(out, act)
37 if err != nil {
38 panic(err)
39 }
40 if !reflect.DeepEqual(exp, act) {
41 panic("not equal")
42 }
43}

Callers

nothing calls this directly

Calls 4

DoMethod · 0.95
getExampleDescFunction · 0.70
getExampleDataFunction · 0.70
NewBinaryConvFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…