github.com/awesome-flow/flow@v0.0.3-0.20190918184116-508d75d68a2c/pkg/util/test/rand.go (about)

     1  package test
     2  
     3  import (
     4  	"math/rand"
     5  	"time"
     6  )
     7  
     8  func init() {
     9  	rand.Seed(time.Now().UnixNano())
    10  }
    11  
    12  const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    13  
    14  func RandBytes(n int) []byte {
    15  	b := make([]byte, n)
    16  	for i := range b {
    17  		b[i] = letterBytes[rand.Intn(len(letterBytes))]
    18  	}
    19  	return b
    20  }
    21  
    22  func RandInt(n int) int {
    23  	return rand.Intn(n)
    24  }