fix: update random seed when call random function

This commit is contained in:
dudaodong
2024-11-11 19:45:31 +08:00
parent f3579fc142
commit a769257017

View File

@@ -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)