go shuffle 源码
洗牌 软件包混洗提供了用于对切片和用户定义的集合进行混洗的原语。 import "github.com/shogo82148/go-shuffle" // Shuffle slice of int. ints := [] int { 3 , 1 , 4 , 1 , 5 , 9 } shuffle . Ints ( ints ) // Shuffle slice of int64. int64s := [] int64 { 3 , 1 , 4 , 1 , 5 , 9 } shuffle . Int64s ( int64s ) // Shuffle slice of string. strings := [] string { "foo" , "bar" } shuffle . Strings ( strings ) // Shuffle slice of float64. float64
用户评论