Skip to content

Commit

Permalink
support textunmarshaler
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Jul 10, 2016
1 parent 2a7dd6f commit 4bc0380
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions decode.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ltsv

import (
"encoding"
"fmt"
"reflect"
"strconv"
Expand Down Expand Up @@ -146,6 +147,13 @@ func Unmarshal(data []byte, v interface{}) error {
}
continue
}
if tu, ok := fv.Interface().(encoding.TextUnmarshaler); ok {
err := tu.UnmarshalText([]byte(s))
if err != nil {
errs[ft.Name] = err
}
continue
}
fallthrough
default:
errs[ft.Name] = &UnmarshalTypeError{s, fv.Type()}
Expand Down

0 comments on commit 4bc0380

Please sign in to comment.