github.com/tobgu/qframe@v0.4.0/internal/maps/maps.go (about) 1 package maps 2 3 import ( 4 "reflect" 5 "sort" 6 7 "github.com/tobgu/qframe/internal/strings" 8 ) 9 10 // StringKeys returns a sorted list of all unique keys present in mm. 11 // This function will panic if mm contains non-maps or maps containing 12 // other key types than string. 13 func StringKeys(mm ...interface{}) []string { 14 keySet := strings.NewStringSet(nil) 15 for _, m := range mm { 16 v := reflect.ValueOf(m) 17 keys := v.MapKeys() 18 for _, k := range keys { 19 keySet.Add(k.String()) 20 } 21 } 22 23 result := keySet.AsSlice() 24 sort.Strings(result) 25 return result 26 }