Last active
December 7, 2016 10:25
-
-
Save rodkranz/6d857c60530ba5d86ccac525cf6b879d to your computer and use it in GitHub Desktop.
Randon Number in Go
This file contains hidden or 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 ( | |
"time" | |
"math/rand" | |
) | |
func init() { | |
rand.Seed(time.Now().UTC().UnixNano()) | |
} | |
func randInt(min int, max int) int { | |
return min + rand.Intn(max-min) | |
} | |
func main() { | |
fmt.Printf("randon: %d", randInt(0, 10)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment