MCPcopy Create free account
hub / github.com/github/gh-aw / formatUnexportedValue

Function formatUnexportedValue

pkg/console/render.go:520–535  ·  view source on GitHub ↗

formatUnexportedValue formats unexported struct fields by kind without using Interface().

(val reflect.Value)

Source from the content-addressed store, hash-verified

518
519// formatUnexportedValue formats unexported struct fields by kind without using Interface().
520func formatUnexportedValue(val reflect.Value) string {
521 switch val.Kind() {
522 case reflect.Bool:
523 return strconv.FormatBool(val.Bool())
524 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
525 return strconv.FormatInt(val.Int(), 10)
526 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
527 return strconv.FormatUint(val.Uint(), 10)
528 case reflect.Float32, reflect.Float64:
529 return fmt.Sprintf("%f", val.Float())
530 case reflect.String:
531 return val.String()
532 default:
533 return val.Type().String()
534 }
535}
536
537// formatNumericKind formats numeric kinds without Interface() as a fallback.
538func formatNumericKind(val reflect.Value) string {

Callers 1

formatFieldValueFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected