Total Lines | 18 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | package serializer |
||
2 | |||
3 | import "fmt" |
||
4 | |||
5 | type rawSerializer struct{} |
||
6 | |||
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 |