MCPcopy
hub / github.com/uber-go/zap / Any

Function Any

field.go:490–625  ·  field.go::Any

Any takes a key and an arbitrary value and chooses the best way to represent them as a field, falling back to a reflection-based approach only if necessary. Since byte/uint8 and rune/int32 are aliases, Any can't differentiate between them. To minimize surprises, []byte values are treated as binary

(key string, value interface{})

Source from the content-addressed store, hash-verified

488// them. To minimize surprises, []byte values are treated as binary blobs, byte
489// values are treated as uint8, and runes are always treated as integers.
490func Any(key string, value interface{}) Field {
491 var c interface{ Any(string, any) Field }
492
493 switch value.(type) {
494 case zapcore.ObjectMarshaler:
495 c = anyFieldC[zapcore.ObjectMarshaler](Object)
496 case zapcore.ArrayMarshaler:
497 c = anyFieldC[zapcore.ArrayMarshaler](Array)
498 case []Field:
499 c = anyFieldC[[]Field](dictField)
500 case bool:
501 c = anyFieldC[bool](Bool)
502 case *bool:
503 c = anyFieldC[*bool](Boolp)
504 case []bool:
505 c = anyFieldC[[]bool](Bools)
506 case complex128:
507 c = anyFieldC[complex128](Complex128)
508 case *complex128:
509 c = anyFieldC[*complex128](Complex128p)
510 case []complex128:
511 c = anyFieldC[[]complex128](Complex128s)
512 case complex64:
513 c = anyFieldC[complex64](Complex64)
514 case *complex64:
515 c = anyFieldC[*complex64](Complex64p)
516 case []complex64:
517 c = anyFieldC[[]complex64](Complex64s)
518 case float64:
519 c = anyFieldC[float64](Float64)
520 case *float64:
521 c = anyFieldC[*float64](Float64p)
522 case []float64:
523 c = anyFieldC[[]float64](Float64s)
524 case float32:
525 c = anyFieldC[float32](Float32)
526 case *float32:
527 c = anyFieldC[*float32](Float32p)
528 case []float32:
529 c = anyFieldC[[]float32](Float32s)
530 case int:
531 c = anyFieldC[int](Int)
532 case *int:
533 c = anyFieldC[*int](Intp)
534 case []int:
535 c = anyFieldC[[]int](Ints)
536 case int64:
537 c = anyFieldC[int64](Int64)
538 case *int64:
539 c = anyFieldC[*int64](Int64p)
540 case []int64:
541 c = anyFieldC[[]int64](Int64s)
542 case int32:
543 c = anyFieldC[int32](Int32)
544 case *int32:
545 c = anyFieldC[*int32](Int32p)
546 case []int32:
547 c = anyFieldC[[]int32](Int32s)

Callers 10

TestEqualsFunction · 0.92
convertAttrToFieldFunction · 0.92
TestFiltersFunction · 0.92
TestFieldConstructorsFunction · 0.85
BenchmarkAnyFunction · 0.85
TestSugarWithFunction · 0.85
sweetenFieldsMethod · 0.85
MarshalLogObjectMethod · 0.85
buildOptionsMethod · 0.85
TestErrorConstructorsFunction · 0.85

Calls 1

AnyMethod · 0.80

Tested by 6

TestEqualsFunction · 0.74
TestFiltersFunction · 0.74
TestFieldConstructorsFunction · 0.68
BenchmarkAnyFunction · 0.68
TestSugarWithFunction · 0.68
TestErrorConstructorsFunction · 0.68