Skip to content

Commit

Permalink
don't quote string before unmarshal text
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoh86 committed Jan 12, 2020
1 parent 30b673a commit a59c1d6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,12 @@ func (d *Decoder) decodeValue(dst reflect.Value, src ast.Node) error {
} else if _, ok := dst.Addr().Interface().(*time.Time); ok {
return d.decodeTime(dst, src)
} else if unmarshaler, isText := dst.Addr().Interface().(encoding.TextUnmarshaler); isText {
b := fmt.Sprintf("%v", src)
var b string
if scalar, isScalar := src.(ast.ScalarNode); isScalar {
b = scalar.GetValue().(string)
} else {
b = src.String()
}
if err := unmarshaler.UnmarshalText([]byte(b)); err != nil {
return errors.Wrapf(err, "failed to UnmarshalText")
}
Expand Down

0 comments on commit a59c1d6

Please sign in to comment.