Golang – How to generate a random integer

Small script to generate a random integer, between 1 and 100, in Golang, the Google programming language.

package main

import (

func random(min, max int) int {
    return rand.Intn(max-min) + min

func main() {

    var myrand int
    myrand = random(1, 101)

Leave a Comment

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