diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 5ad8f51..2b6a425 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -44,7 +44,7 @@ func (app *application) createElection(w http.ResponseWriter, r *http.Request) { if request.AreVotersKnown { voterIdentities := make([]string, 0, request.MaxVoters) for i := 0; i < request.MaxVoters; i++ { - randomIdentity := generateRandomVoterIdentity() + randomIdentity := randomVoterIdentity() _, err := app.voters.Insert(randomIdentity, electionId) if err != nil { app.serverError(w, r, err) @@ -77,7 +77,7 @@ func isRequestValid(r *createElectionRequestWithValidator) bool { return r.Valid() } -func generateRandomVoterIdentity() string { +func randomVoterIdentity() string { const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" b := make([]byte, 16) for i := range b {