Created
October 8, 2019 13:06
-
-
Save dingdayu/05f0f2238ec209753cca4d3f4672f8e6 to your computer and use it in GitHub Desktop.
Go 生成区间随机数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math/rand" | |
) | |
// Random 根据区间产生随机数 | |
func Random(min, max int) int { | |
rand.Seed(time.Now().Unix()) | |
return rand.Intn(max-min) + min | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment