MCPcopy
hub / github.com/pelletier/go-toml / assignString

Method assignString

unmarshaler.go:1692–1709  ·  view source on GitHub ↗
(v reflect.Value, value *unstable.Node)

Source from the content-addressed store, hash-verified

1690}
1691
1692func (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
1711func (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

Callers 1

assignValueMethod · 0.95

Calls 5

typeMismatchErrorMethod · 0.95
NewParserErrorFunction · 0.92
boxIntoFunction · 0.85
RawMethod · 0.80
UnmarshalTextMethod · 0.45

Tested by

no test coverage detected