diff --git a/main.go b/main.go index 711d1d6..949b25c 100644 --- a/main.go +++ b/main.go @@ -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:] + } + +}