mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-27 12:28:40 +08:00
15 lines
232 B
Go
15 lines
232 B
Go
|
package resolver
|
||
|
|
||
|
import "math/rand"
|
||
|
|
||
|
func subset(set []string, sub int) []string {
|
||
|
rand.Shuffle(len(set), func(i, j int) {
|
||
|
set[i], set[j] = set[j], set[i]
|
||
|
})
|
||
|
if len(set) <= sub {
|
||
|
return set
|
||
|
} else {
|
||
|
return set[:sub]
|
||
|
}
|
||
|
}
|