mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-04 06:36:30 +08:00
18 lines
316 B
Go
18 lines
316 B
Go
package mapUtil
|
||
|
||
import (
|
||
"fmt"
|
||
"sort"
|
||
)
|
||
|
||
func ExampleExtractKeys() {
|
||
m := map[string]int{"apple": 5, "banana": 3, "orange": 7}
|
||
keys := ExtractKeys(m)
|
||
|
||
// 对结果排序以确保输出一致(map 迭代顺序随机)
|
||
sort.Strings(keys)
|
||
fmt.Println("Keys:", keys)
|
||
|
||
// Output: Keys: [apple banana orange]
|
||
}
|