serializer.*rawSerializer.Serialize   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 8
nop 2
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 4
rs 10
c 0
b 0
f 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