Skip to content

Commit

Permalink
refactor: update random number generation to use rand.NewSource in Go…
Browse files Browse the repository at this point in the history
… 1.20
  • Loading branch information
revelaction committed Sep 28, 2024
1 parent f2dc8b7 commit 46d94c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ func (c *Config) Image(name string) (Image, bool) {
if len(matchingImages) == 0 {
return Image{}, false
}
rand.Seed(time.Now().UnixNano())
randomIndex := rand.Intn(len(matchingImages))
source := rand.NewSource(time.Now().UnixNano())
rng := rand.New(source)
randomIndex := rng.Intn(len(matchingImages))
return matchingImages[randomIndex], true
}

Expand Down

0 comments on commit 46d94c5

Please sign in to comment.