Last active
October 14, 2021 14:16
-
-
Save nicolasparada/55f35cd7c2b8955bd03df3a390d5a18b to your computer and use it in GitHub Desktop.
Quick and easy way to generate a random string in golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func main() { | |
rand.Seed(time.Now().UnixNano()) | |
randStr := fmt.Sprintf("%x", rand.Int63()) | |
fmt.Println(randStr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment