Rename function
This commit is contained in:
@ -44,7 +44,7 @@ func (app *application) createElection(w http.ResponseWriter, r *http.Request) {
|
|||||||
if request.AreVotersKnown {
|
if request.AreVotersKnown {
|
||||||
voterIdentities := make([]string, 0, request.MaxVoters)
|
voterIdentities := make([]string, 0, request.MaxVoters)
|
||||||
for i := 0; i < request.MaxVoters; i++ {
|
for i := 0; i < request.MaxVoters; i++ {
|
||||||
randomIdentity := generateRandomVoterIdentity()
|
randomIdentity := randomVoterIdentity()
|
||||||
_, err := app.voters.Insert(randomIdentity, electionId)
|
_, err := app.voters.Insert(randomIdentity, electionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.serverError(w, r, err)
|
app.serverError(w, r, err)
|
||||||
@ -77,7 +77,7 @@ func isRequestValid(r *createElectionRequestWithValidator) bool {
|
|||||||
return r.Valid()
|
return r.Valid()
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateRandomVoterIdentity() string {
|
func randomVoterIdentity() string {
|
||||||
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
b := make([]byte, 16)
|
b := make([]byte, 16)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
|
Reference in New Issue
Block a user