MCPcopy Index your code
hub / github.com/labstack/echo / unmarshalInputToField

Function unmarshalInputToField

bind.go:421–450  ·  view source on GitHub ↗
(valueKind reflect.Kind, val string, field reflect.Value, formatTag string)

Source from the content-addressed store, hash-verified

419}
420
421func unmarshalInputToField(valueKind reflect.Kind, val string, field reflect.Value, formatTag string) (bool, error) {
422 if valueKind == reflect.Pointer {
423 if field.IsNil() {
424 field.Set(reflect.New(field.Type().Elem()))
425 }
426 field = field.Elem()
427 }
428
429 fieldIValue := field.Addr().Interface()
430 // Handle time.Time with custom format tag
431 if formatTag != "" {
432 if _, isTime := fieldIValue.(*time.Time); isTime {
433 t, err := time.Parse(formatTag, val)
434 if err != nil {
435 return true, err
436 }
437 field.Set(reflect.ValueOf(t))
438 return true, nil
439 }
440 }
441
442 switch unmarshaler := fieldIValue.(type) {
443 case BindUnmarshaler:
444 return true, unmarshaler.UnmarshalParam(val)
445 case encoding.TextUnmarshaler:
446 return true, unmarshaler.UnmarshalText([]byte(val))
447 }
448
449 return false, nil
450}
451
452func setIntField(value string, bitSize int, field reflect.Value) error {
453 if value == "" {

Callers 2

bindDataFunction · 0.85
setWithProperTypeFunction · 0.85

Calls 3

SetMethod · 0.80
UnmarshalTextMethod · 0.80
UnmarshalParamMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…