github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/os/uuid.go (about)

     1  package os
     2  
     3  import "math/rand"
     4  
     5  //http://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang
     6  const letterBytes = "abcdefghijklmnopqrstuvwxyz"
     7  
     8  func RandStringBytes(n int) string {
     9  	b := make([]byte, n)
    10  	for i := range b {
    11  		b[i] = letterBytes[rand.Intn(len(letterBytes))]
    12  	}
    13  	return string(b)
    14  }