marshalSorted recursively marshals data with sorted keys
(data any)
| 46 | |
| 47 | // marshalSorted recursively marshals data with sorted keys |
| 48 | func marshalSorted(data any) string { |
| 49 | switch v := data.(type) { |
| 50 | case map[string]any: |
| 51 | return marshalSortedMap(v) |
| 52 | |
| 53 | case []any: |
| 54 | return marshalSortedSlice(v) |
| 55 | |
| 56 | case string, int, int64, float64, bool, nil: |
| 57 | return marshalSortedValue(v, "primitive value") |
| 58 | |
| 59 | default: |
| 60 | return marshalSortedValue(v, fmt.Sprintf("value of type %T", v)) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func marshalSortedMap(v map[string]any) string { |
| 65 | if len(v) == 0 { |