Skip to content

Commit

Permalink
fix: update random seed when call random function
Browse files Browse the repository at this point in the history
  • Loading branch information
duke-git committed Nov 11, 2024
1 parent f3579fc commit a769257
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ func nearestPowerOfTwo(cap int) int {

// random generate a random string based on given string range.
func random(s string, length int) string {
// 确保随机数生成器的种子是动态的
rand.Seed(time.Now().UnixNano())

// 仿照strings.Builder
// 创建一个长度为 length 的字节切片
bytes := make([]byte, length)
Expand Down

0 comments on commit a769257

Please sign in to comment.