Golang | Get a random number within a range

package main

import (
	"fmt"
	"math/rand"
	"strconv"
	"time"
)

func random(min, max int) int {
	rand.Seed(time.Now().UTC().UnixNano())
	return rand.Intn(max-min) + min
}

func main() {

	myrand := random(1, 91)
	fmt.Println(strconv.Itoa(myrand))
    
}

Leave a Comment

Your email address will not be published. Required fields are marked *