MCPcopy
hub / github.com/moonD4rk/HackBrowserData / fieldToString

Function fieldToString

output/reflect.go:59–75  ·  view source on GitHub ↗
(v reflect.Value)

Source from the content-addressed store, hash-verified

57}
58
59func fieldToString(v reflect.Value) string {
60 // Check time.Time before kind switch since it's a struct.
61 if v.Type() == timeType {
62 t, _ := v.Interface().(time.Time)
63 return formatTime(t)
64 }
65 switch v.Kind() {
66 case reflect.String:
67 return v.String()
68 case reflect.Bool:
69 return formatBool(v.Bool())
70 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
71 return strconv.FormatInt(v.Int(), 10)
72 default:
73 return fmt.Sprintf("%v", v.Interface())
74 }
75}
76
77func formatTime(t time.Time) string {
78 if t.IsZero() {

Callers 1

structCSVRowFunction · 0.85

Calls 4

formatTimeFunction · 0.85
formatBoolFunction · 0.85
KindMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected