golang 生成随机数


package main


import (
    "fmt"
    "math/rand"
    "bytes"
)

func main() {
    fmt.Println( time.Now().UTC().UnixNano() )
}


func randomString (l int ) string {
    var result   bytes.Buffer
    var temp string
    for i:=0 ; i<l ;  {
        temp = string(randInt(65,90))
        result.WriteString(temp)
        i++
      
    }
	return result.String()
}

func randInt(min int , max int) int {
        return min + rand.Intn(max-min)
}



你可能感兴趣的:(golang 生成随机数)