golang取两个数字之间的随机数
package main import ( "crypto/rand" "math/big" "fmt" ) func main(){ fmt.Println(RandInt64(100,3000)) } func RandInt64(min,max int64) int64{ maxBigInt:=big.NewInt(max) i,_:=rand.Int(rand.Reader,maxBigInt) if i.Int64()<min{ RandInt64(min,max) } return i.Int64() }