Skip to content

Commit 537506b

Browse files
ms2008xcaspar
authored andcommitted
fix: setting once initially for seed PRNG
Signed-off-by: ms2008 <ms2008vip@gmail.com>
1 parent a95ad0a commit 537506b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

util/util.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ var binPath string
4444
var libPath string
4545
var yamlPath string
4646

47+
func init() {
48+
rand.Seed(time.Now().UnixNano())
49+
}
50+
4751
// GetProgramPath
4852
func GetProgramPath() string {
4953
if proPath != "" {
@@ -91,7 +95,6 @@ func GetYamlHome() string {
9195

9296
// GenerateUid for exp
9397
func GenerateUid() (string, error) {
94-
rand.Seed(time.Now().UnixNano())
9598
b := make([]byte, 8)
9699
_, err := rand.Read(b)
97100
if err != nil {

0 commit comments

Comments
 (0)