| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Coverage | 80% |
| Changes | 0 | ||
| 1 | package decode |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "io" |
||
| 5 | "reflect" |
||
| 6 | ) |
||
| 7 | |||
| 8 | type Decoder struct { |
||
| 9 | r io.Reader |
||
| 10 | } |
||
| 11 | |||
| 12 | func NewDecoder(r io.Reader) *Decoder { |
||
| 13 | 1 | return &Decoder{r} |
|
| 14 | } |
||
| 15 | |||
| 16 | func (dec *Decoder) Decode(v interface{}) error { |
||
| 17 | 1 | rv := reflect.ValueOf(v) |
|
| 18 | 1 | if rv.Kind() != reflect.Ptr || rv.IsNil() { |
|
| 19 | return &InvalidUnmarshalError{reflect.TypeOf(v)} |
||
| 20 | } |
||
| 21 | |||
| 22 | 1 | return decode(dec.r, v) |
|
| 23 | } |
||
| 24 |