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

Function bindValue

binder_generic.go:405–571  ·  view source on GitHub ↗
(value string, dest any, opts ...any)

Source from the content-addressed store, hash-verified

403}
404
405func bindValue(value string, dest any, opts ...any) error {
406 // NOTE: if this function is ever made public the dest should be checked for nil
407 // values when dealing with interfaces
408 if len(opts) > 0 {
409 if _, isTime := dest.(*time.Time); !isTime {
410 return fmt.Errorf("options are only supported for time.Time, got %T", dest)
411 }
412 }
413
414 switch d := dest.(type) {
415 case *bool:
416 n, err := strconv.ParseBool(value)
417 if err != nil {
418 return err
419 }
420 *d = n
421 case *float32:
422 n, err := strconv.ParseFloat(value, 32)
423 if err != nil {
424 return err
425 }
426 *d = float32(n)
427 case *float64:
428 n, err := strconv.ParseFloat(value, 64)
429 if err != nil {
430 return err
431 }
432 *d = n
433 case *int:
434 n, err := strconv.ParseInt(value, 10, 0)
435 if err != nil {
436 return err
437 }
438 *d = int(n)
439 case *int8:
440 n, err := strconv.ParseInt(value, 10, 8)
441 if err != nil {
442 return err
443 }
444 *d = int8(n)
445 case *int16:
446 n, err := strconv.ParseInt(value, 10, 16)
447 if err != nil {
448 return err
449 }
450 *d = int16(n)
451 case *int32:
452 n, err := strconv.ParseInt(value, 10, 32)
453 if err != nil {
454 return err
455 }
456 *d = int32(n)
457 case *int64:
458 n, err := strconv.ParseInt(value, 10, 64)
459 if err != nil {
460 return err
461 }
462 *d = n

Callers 1

ParseValueOrFunction · 0.85

Calls 4

TimeLayoutTypeAlias · 0.85
UnmarshalTextMethod · 0.80
UnmarshalJSONMethod · 0.80
UnmarshalParamMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…