Skip to content

Instantly share code, notes, and snippets.

@dingdayu
Created October 8, 2019 13:06
Show Gist options
  • Save dingdayu/05f0f2238ec209753cca4d3f4672f8e6 to your computer and use it in GitHub Desktop.
Save dingdayu/05f0f2238ec209753cca4d3f4672f8e6 to your computer and use it in GitHub Desktop.
Go 生成区间随机数
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