lundi 25 février 2019

GOlang Random number + database

I am curious to look at how I would make this work, My idea is: Whenever i run the program i want it to generate a Random number, this number should be logged in some document so it wont EVER generate this number twice.

package main

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

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

// NummerGenerator between 1 & 99999
func main() {
rand.Seed(time.Now().UnixNano())
randomNum := random(1, 99999)
fmt.Printf("Random Num: %d\n", randomNum)
}

(this would be the Number generator)




Aucun commentaire:

Enregistrer un commentaire