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

Method int

binder.go:536–560  ·  view source on GitHub ↗
(sourceParam string, value string, dest any, bitSize int)

Source from the content-addressed store, hash-verified

534}
535
536func (b *ValueBinder) int(sourceParam string, value string, dest any, bitSize int) *ValueBinder {
537 n, err := strconv.ParseInt(value, 10, bitSize)
538 if err != nil {
539 if bitSize == 0 {
540 b.setError(b.ErrorFunc(sourceParam, []string{value}, "failed to bind field value to int", err))
541 } else {
542 b.setError(b.ErrorFunc(sourceParam, []string{value}, fmt.Sprintf("failed to bind field value to int%v", bitSize), err))
543 }
544 return b
545 }
546
547 switch d := dest.(type) {
548 case *int64:
549 *d = n
550 case *int32:
551 *d = int32(n) // #nosec G115
552 case *int16:
553 *d = int16(n) // #nosec G115
554 case *int8:
555 *d = int8(n) // #nosec G115
556 case *int:
557 *d = int(n)
558 }
559 return b
560}
561
562func (b *ValueBinder) intsValue(sourceParam string, dest any, valueMustExist bool) *ValueBinder {
563 if b.failFast && b.errors != nil {

Callers 2

intValueMethod · 0.95
intsMethod · 0.95

Calls 1

setErrorMethod · 0.95

Tested by

no test coverage detected