Conditions | 4 |
Total Lines | 12 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4 |
Changes | 0 |
1 | package serializer |
||
7 | func (*rawSerializer) Serialize(data interface{}, format string) ([]byte, error) { |
||
8 | 1 | if bytes, ok := data.([]byte); ok { |
|
9 | 1 | return bytes, nil |
|
10 | } |
||
11 | 1 | if s, ok := data.(string); ok { |
|
12 | 1 | return []byte(s), nil |
|
13 | } |
||
14 | 1 | if s, ok := data.(fmt.Stringer); ok { |
|
15 | 1 | return []byte(s.String()), nil |
|
16 | } |
||
17 | |||
18 | 1 | return nil, ErrUnserializableData |
|
19 | } |
||
20 |