Skip to content

Instantly share code, notes, and snippets.

@rodkranz
Last active December 7, 2016 10:25
Show Gist options
  • Save rodkranz/6d857c60530ba5d86ccac525cf6b879d to your computer and use it in GitHub Desktop.
Save rodkranz/6d857c60530ba5d86ccac525cf6b879d to your computer and use it in GitHub Desktop.
Randon Number in Go
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