mirror of
https://github.com/IllusionMan1212/kotapi-go.git
synced 2026-10-24 10:12:29 +00:00
make RNG inclusive on both ends
This commit is contained in:
+2
-2
@@ -39,8 +39,8 @@ func RandomHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
min := 1
|
min := 1
|
||||||
// seed the default source using the current time in unix nanosecond format
|
// seed the default source using the current time in unix nanosecond format
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
// generate random number between min and `max`
|
// generate random number between min and max [min, max]
|
||||||
num := rand.Intn(int(max)-min) + min
|
num := rand.Intn(int(max+1)-min) + min
|
||||||
|
|
||||||
// find the random kot document and store it in the `kot` variable
|
// find the random kot document and store it in the `kot` variable
|
||||||
err = db.Kots.FindOne(db.Ctx, bson.M{"id": num}).Decode(&kot)
|
err = db.Kots.FindOne(db.Ctx, bson.M{"id": num}).Decode(&kot)
|
||||||
|
|||||||
Reference in New Issue
Block a user