2948 explained code solutions for 75 technologies

golangHow to generate random int

package main
import ("math/rand"; "time")

func main() {
  rnd := rand.New( rand.NewSource(time.Now().UnixNano()) )
  num := rnd.Intn(25)
}ctrl + c
package main

default package declaration


lib for random numbers generation


init new random generator with given seed


returns random number from 0 to the given number (25 in our case)


will contain random int