MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / MapKeys

Function MapKeys

pkg/util/test/elements.go:115–128  ·  view source on GitHub ↗

MapKeys returns the keys of a map as a slice.

(m any)

Source from the content-addressed store, hash-verified

113
114// MapKeys returns the keys of a map as a slice.
115func MapKeys(m any) []any {
116 if m == nil {
117 return nil
118 }
119 rv := reflect.ValueOf(m)
120 if rv.Kind() != reflect.Map {
121 panic(fmt.Errorf("expected %T to be of map type", m))
122 }
123 ks := make([]any, 0, rv.Len())
124 for _, k := range rv.MapKeys() {
125 ks = append(ks, k.Interface())
126 }
127 return ks
128}
129
130// IsSubsetOfElements returns true iff a multiset sub represents a subset of
131// multiset super under equality given by eq.

Callers

nothing calls this directly

Calls 2

ErrorfMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected