Skip to content

Commit 48b36a6

Browse files
committed
go: rand的坑
1 parent 0c2c398 commit 48b36a6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

go-note/tricks.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,11 @@ Go Context 的坑
908908
909909
- https://zhuanlan.zhihu.com/p/34417106 《Go Context的踩坑经历》
910910

911+
Go rand 的坑
912+
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
913+
如果忘记调用 `rand.Seed(time.Now().UnixNano())` 每次重新运行返回结果是相同的,应该在程序初始化的时候比如 init 函数调用一次 seed。
914+
915+
911916
redio tricks
912917
--------------------------------------------------
913918

0 commit comments

Comments
 (0)