Deleted local winner log, winner list length capped to 20
All checks were successful
Release / publish (push) Successful in 1m0s

This commit is contained in:
Gian Breitenstein 2024-09-26 19:07:12 +02:00
parent 2d50e61403
commit 966a0bbf4a

12
main.go
View File

@ -2,7 +2,6 @@ package main
import (
"fmt"
"log"
"math/rand"
"net/http"
"strconv"
@ -34,10 +33,8 @@ func randomNumber(w http.ResponseWriter, r *http.Request) {
return
}
won := randomize(chance, multiplicator)
log.Println(name)
if name != "" && won {
winners = append(winners, name)
fmt.Println(winners)
appendUser(name)
}
fmt.Fprint(w, won)
@ -65,3 +62,10 @@ func listWiners(w http.ResponseWriter, r *http.Request) {
}
fmt.Fprint(w, out)
}
func appendUser(username string) {
winners = append(winners, username)
if len(winners) > 20 {
winners = winners[1:]
}
}