Skip to content

Commit

Permalink
Fix issue that caused cards to have same ID
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkpickering committed Feb 9, 2023
1 parent 680d77e commit af19adc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/models/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const (

const letters = "abcdefghijklmnopqrstuvwxyz0123456789"

func init() {
rand.Seed(time.Now().UnixNano())
}

type Card struct {
ID string `json:"id"`
Deck string `json:"-"`
Expand All @@ -31,7 +35,6 @@ type Card struct {
// From https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go
func randomString(n int) string {
b := make([]byte, n)
rand.Seed(time.Now().UnixNano())
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
Expand Down

0 comments on commit af19adc

Please sign in to comment.