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

Function marshalSorted

pkg/parser/frontmatter_hash.go:48–62  ·  view source on GitHub ↗

marshalSorted recursively marshals data with sorted keys

(data any)

Source from the content-addressed store, hash-verified

46
47// marshalSorted recursively marshals data with sorted keys
48func 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
64func marshalSortedMap(v map[string]any) string {
65 if len(v) == 0 {

Calls 3

marshalSortedMapFunction · 0.85
marshalSortedSliceFunction · 0.85
marshalSortedValueFunction · 0.85