To create a random token in Golang. Based on letters, numbers and symbols. Created with a non-negative pseudo-random number based on a random seed with is created with unix time number of nanoseconds.
First you have to install the package. You can do this as follows:
go get github.com/gowizzard/goten
Here is a small example how to create a random password without numbers and symbols. Only letters.
token := goten.Generate(50, nil)
fmt.Println(token)
And here is a small example how to create a random token with numbers and symbols.
options := goten.Options{
Uppercase: true,
Numbers: true,
Symbols: true,
}
token := goten.Generate(50, &options)
fmt.Println(token)