formatTimeValue formats a time.Time reflect value as a display string.
(val reflect.Value)
| 500 | |
| 501 | // formatTimeValue formats a time.Time reflect value as a display string. |
| 502 | func formatTimeValue(val reflect.Value) string { |
| 503 | if val.CanInterface() { |
| 504 | if timeVal, ok := val.Interface().(time.Time); ok { |
| 505 | return formatConfiguredTimeValue(timeVal) |
| 506 | } |
| 507 | } |
| 508 | // For unexported time.Time fields, try to call the String method |
| 509 | stringMethod := val.MethodByName("String") |
| 510 | if stringMethod.IsValid() { |
| 511 | result := stringMethod.Call(nil) |
| 512 | if len(result) > 0 { |
| 513 | return result[0].String() |
| 514 | } |
| 515 | } |
| 516 | return val.Type().String() |
| 517 | } |
| 518 | |
| 519 | // formatUnexportedValue formats unexported struct fields by kind without using Interface(). |
| 520 | func formatUnexportedValue(val reflect.Value) string { |
no test coverage detected