Skip to content

Commit

Permalink
add MapKeys method
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz committed May 13, 2024
1 parent f366b7b commit 398c61e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions algorithms/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ func MapValues[K comparable, V any](m map[K]V) []V {
return s
}

func MapKeys[K comparable, V any](m map[K]V) []K {
s := make([]K, 0, len(m))
for k, _ := range m {

Check failure on line 13 in algorithms/map.go

View workflow job for this annotation

GitHub Actions / Lint

S1005: unnecessary assignment to the blank identifier (gosimple)
s = append(s, k)
}
return s
}

func Merge(maps ...map[string]interface{}) map[string]interface{} {
res := maps[0]
for _, m := range maps[1:] {
Expand Down

0 comments on commit 398c61e

Please sign in to comment.