From 4bc03800bb5a4289d89234037556611f562b6d57 Mon Sep 17 00:00:00 2001 From: Songmu Date: Sun, 10 Jul 2016 16:57:04 +0900 Subject: [PATCH] support textunmarshaler --- decode.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/decode.go b/decode.go index 43550cb..ac1e056 100644 --- a/decode.go +++ b/decode.go @@ -1,6 +1,7 @@ package ltsv import ( + "encoding" "fmt" "reflect" "strconv" @@ -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()}