Selaa lähdekoodia

feat:随机数

wangshan 2 vuotta sitten
vanhempi
commit
8c776e6ff2
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      jyBXBuyer/rpc/service/service.go

+ 2 - 2
jyBXBuyer/rpc/service/service.go

@@ -21,9 +21,9 @@ func GetRelatesInfo(in *bxbuyer.RelatesInformationReq) *bxbuyer.RelatesInformati
 	}
 	//获取随机数
 	// 使用当前时间作为随机数生成器的种子
-	rand.Seed(time.Now().UnixNano())
+	randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
 	// 获取一个范围在 [0, 100) 的随机整数
-	start := rand.Intn(100)
+	start := randGen.Intn(100)
 	//关联采购单位:同省份采购单位名称随机展示30个
 	if in.Area != "" {
 		in.Area = fmt.Sprintf(`,{"term": {"province": "%s"}`, in.Area)