mirror of
https://github.com/duke-git/lancet.git
synced 2025-09-27 03:45:58 +08:00
fix: update random seed when call random function
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user