Debian Codegraph @

test/foo/foo.go

raw symbols SCIP
1 package foo
2
3 type fooCodec struct {
4 }
5
6 func (fooCodec) Marshal(v interface{}) ([]byte, error) {
7 switch t := v.(type) {
8 case *Request:
9 return []byte(t.In), nil
10 case *Response:
11 return []byte(t.Out), nil
12 default:
13 panic("invalid type")
14 }
15 }
16
17 func (fooCodec) Unmarshal(data []byte, v interface{}) error {
18 str := string(data)
19 switch t := v.(type) {
20 case *Request:
21 t.In = str
22 case *Response:
23 t.Out = str
24 default:
25 panic("invalid type")
26 }
27 return nil
28 }
29
30 func (fooCodec) String() string {
31 return "FooCodec"
32 }