github.com/rolandhe/saber@v0.0.4/utils/rand/randutil.go (about) 1 // Package randutil, rand tool 2 // 3 // Copyright 2023 The saber Authors. All rights reserved. 4 5 // Package randutil 使用go linkname技术暴露runtime 私有函数,以提高性能 6 package randutil 7 8 import _ "unsafe" 9 10 // FastRandN 0 ~ n 范围的随机数 11 // 12 //go:linkname FastRandN runtime.fastrandn 13 func FastRandN(n uint32) uint32 14 15 // FastRand 生成一个64位的随机数 16 // 17 //go:linkname FastRand runtime.fastrand64 18 func FastRand() uint64