Last active
October 31, 2020 02:03
-
-
Save dilumdesilva/4ca13c3c212ea786fa83f7a3816b43da to your computer and use it in GitHub Desktop.
Useful golang code snippets
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
//Improved random number generator | |
source := rand.NewSource(time.Now().UnixNano()) | |
r := rand.New(source) | |
newPos := r.Intn(len(slice) - 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment