MCPcopy Create free account
hub / github.com/alecthomas/kong / timeDecoder

Function timeDecoder

mapper.go:351–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

349}
350
351func timeDecoder() MapperFunc {
352 return func(ctx *DecodeContext, target reflect.Value) error {
353 format := time.RFC3339
354 if ctx.Value.Format != "" {
355 format = ctx.Value.Format
356 }
357 var value string
358 if err := ctx.Scan.PopValueInto("time", &value); err != nil {
359 return err
360 }
361 t, err := time.Parse(format, value)
362 if err != nil {
363 return err
364 }
365 target.Set(reflect.ValueOf(t))
366 return nil
367 }
368}
369
370func intDecoder(bits int) MapperFunc { //nolint: dupl
371 return func(ctx *DecodeContext, target reflect.Value) error {

Callers 1

RegisterDefaultsMethod · 0.85

Calls 3

PopValueIntoMethod · 0.80
SetMethod · 0.80
ParseMethod · 0.45

Tested by

no test coverage detected