ToString returns the string representation of the given type.
(val any)
| 413 | |
| 414 | // ToString returns the string representation of the given type. |
| 415 | func ToString(val any) string { |
| 416 | switch actual := val.(type) { |
| 417 | case string: |
| 418 | return actual |
| 419 | case int: |
| 420 | return strconv.Itoa(actual) |
| 421 | case float64: |
| 422 | return strconv.FormatFloat(actual, 'f', -1, 64) |
| 423 | case bool: |
| 424 | return strconv.FormatBool(actual) |
| 425 | default: |
| 426 | panic("unexpected key type") |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | // ToStringMap converts map[any]any to a map[string]any |
| 431 | // when possible. |