Files
go-easy-utils/mapx/keys_example_test.go
2025-07-08 15:26:54 +08:00

18 lines
299 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package mapx
import (
"fmt"
"sort"
)
func ExampleKeys() {
m := map[string]int{"apple": 5, "banana": 3, "orange": 7}
keys := Keys(m)
// 对结果排序以确保输出一致map 迭代顺序随机)
sort.Strings(keys)
fmt.Println("Keys:", keys)
// Output: Keys: [apple banana orange]
}