Random String Go

[Solved] Random String Go | Swift - Code Explorer | yomemimo.com
Question : random string go

Answered by : restu-wahyu-saputra

const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
func RandStringBytes(n int) string { b := make([]byte, n) for i := range b { b[i] = letterBytes[rand.Intn(len(letterBytes))] } return string(b)
}

Source : https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go | Last Update : Sat, 01 May 21

Question : golang generate random string

Answered by : defiant-dove-qes2so4jpzh7

package main
import ( "fmt" "time" "math/rand"
)
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func randSeq(n int) string { b := make([]rune, n) for i := range b { b[i] = letters[rand.Intn(len(letters))] } return string(b)
}
func main() { rand.Seed(time.Now().UnixNano()) fmt.Println(randSeq(10))
}

Source : https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go | Last Update : Tue, 11 Jan 22

Question : random string go

Answered by : restu-wahyu-saputra

func StringWithCharset(length int, charset string) string { b := make([]byte, length) for i := range b { b[i] = charset[seededRand.Intn(len(charset))] } return string(b)
}

Source : https://www.calhoun.io/creating-random-strings-in-go/ | Last Update : Sat, 01 May 21

Answers related to random string go

Code Explorer Popular Question For Swift