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

Function ExampleBinaryConv_Do

conv/p2j/example_test.go:17–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15var opts = conv.Options{}
16
17func ExampleBinaryConv_Do() {
18 // get descriptor and data
19 includeDirs := util_test.MustGitPath("testdata/idl/") // includeDirs is used to find the include files.
20 desc := proto.FnRequest(proto.GetFnDescFromFile(exampleIDLPath, "ExampleMethod", proto.Options{}, includeDirs))
21
22 // make BinaryConv
23 cv := NewBinaryConv(conv.Options{})
24 in := readExampleReqProtoBufData()
25
26 // do conversion
27 out, err := cv.Do(context.Background(), desc, in)
28 if err != nil {
29 panic(err)
30 }
31 exp := example2.ExampleReq{}
32
33 // use proto.Unmarshal to check proto data validity
34 err = goproto.Unmarshal(readExampleReqProtoBufData(), &exp)
35 if err != nil {
36 panic(err)
37 }
38
39 // validate result
40 var act example2.ExampleReq
41 err = json.Unmarshal([]byte(out), &act)
42 if err != nil {
43 panic(err)
44 }
45 if !reflect.DeepEqual(exp, act) {
46 panic("not equal")
47 }
48}

Callers

nothing calls this directly

Calls 4

DoMethod · 0.95
MustGitPathFunction · 0.92
NewBinaryConvFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…