(v reflect.Value, value *unstable.Node)
| 1690 | } |
| 1691 | |
| 1692 | func (d *decoder) assignString(v reflect.Value, value *unstable.Node) (reflect.Value, error) { |
| 1693 | switch v.Kind() { |
| 1694 | case reflect.String: |
| 1695 | v.SetString(string(value.Data)) |
| 1696 | return v, nil |
| 1697 | case reflect.Interface: |
| 1698 | return boxInto(v, reflect.ValueOf(string(value.Data))) |
| 1699 | default: |
| 1700 | } |
| 1701 | if v.CanAddr() && v.Addr().Type().Implements(textUnmarshalerType) { |
| 1702 | err := v.Addr().Interface().(encoding.TextUnmarshaler).UnmarshalText(value.Data) |
| 1703 | if err != nil { |
| 1704 | return reflect.Value{}, unstable.NewParserError(d.p.Raw(value.Raw), "%s", err) |
| 1705 | } |
| 1706 | return v, nil |
| 1707 | } |
| 1708 | return reflect.Value{}, d.typeMismatchError("string", v.Type(), d.p.Raw(value.Raw)) |
| 1709 | } |
| 1710 | |
| 1711 | func (d *decoder) assignInteger(v reflect.Value, value *unstable.Node) (reflect.Value, error) { |
| 1712 | // Integer values targeting a float field are parsed as floats: they can |
no test coverage detected