formatted winners
All checks were successful
Release / publish (push) Successful in 57s

This commit is contained in:
Gian Breitenstein 2024-09-26 18:24:40 +02:00
parent 5cae25cb2f
commit 6883ce679e

View File

@ -30,7 +30,7 @@ func randomNumber(w http.ResponseWriter, r *http.Request) {
} }
won := randomize(chance, multiplicator) won := randomize(chance, multiplicator)
log.Println(name) log.Println(name)
if name != "" { if name != "" && won {
winners = append(winners, name) winners = append(winners, name)
fmt.Println(winners) fmt.Println(winners)
} }
@ -54,5 +54,9 @@ func randomize(chance int, mult int) bool {
} }
} }
func listWiners(w http.ResponseWriter, r *http.Request) { func listWiners(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, winners) out := ""
for _, winner := range winners {
out += winner + "\n"
}
fmt.Fprint(w, out)
} }