Conditions | 3 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3.0175 |
Changes | 0 |
1 | // Package decode implements BINN decoding. |
||
15 | func Unmarshal(data []byte, v interface{}) error { |
||
16 | 1 | decoder := NewDecoder(bytes.NewReader(data)) |
|
17 | |||
18 | 1 | rt := reflect.TypeOf(v) |
|
19 | |||
20 | 1 | if rt.Implements(unmarshalerType) { |
|
21 | 1 | err := decodeUnmarshaler(data, v) |
|
22 | 1 | if err != nil { |
|
23 | return err |
||
24 | } |
||
25 | |||
26 | 1 | return nil |
|
27 | } |
||
28 | |||
29 | 1 | return decoder.Decode(v) |
|
30 | } |
||
46 |