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

Method duration

binder.go:1188–1207  ·  view source on GitHub ↗
(sourceParam string, dest *time.Duration, valueMustExist bool)

Source from the content-addressed store, hash-verified

1186}
1187
1188func (b *ValueBinder) duration(sourceParam string, dest *time.Duration, valueMustExist bool) *ValueBinder {
1189 if b.failFast && b.errors != nil {
1190 return b
1191 }
1192
1193 value := b.ValueFunc(sourceParam)
1194 if value == "" {
1195 if valueMustExist {
1196 b.setError(b.ErrorFunc(sourceParam, []string{value}, "required field value is empty", nil))
1197 }
1198 return b
1199 }
1200 t, err := time.ParseDuration(value)
1201 if err != nil {
1202 b.setError(b.ErrorFunc(sourceParam, []string{value}, "failed to bind field value to Duration", err))
1203 return b
1204 }
1205 *dest = t
1206 return b
1207}
1208
1209// Durations binds parameter values to slice of time.Duration variables
1210func (b *ValueBinder) Durations(sourceParam string, dest *[]time.Duration) *ValueBinder {

Callers 2

DurationMethod · 0.95
MustDurationMethod · 0.95

Calls 1

setErrorMethod · 0.95

Tested by

no test coverage detected