Conditions | 5 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | package encode |
||
19 | func textMarshalerEncoder(v reflect.Value) ([]byte, error) { |
||
20 | if v.Kind() == reflect.Ptr && v.IsNil() { |
||
21 | return []byte{binn.Null}, nil |
||
22 | } |
||
23 | |||
24 | m, ok := v.Interface().(encoding.TextMarshaler) |
||
25 | if !ok { |
||
26 | return []byte{binn.Null}, nil |
||
27 | } |
||
28 | b, err := m.MarshalText() |
||
29 | if err != nil { |
||
30 | return nil, err |
||
31 | } |
||
32 | |||
33 | return String(string(b)), nil |
||
34 | } |
||
35 |