[management] remove old math rand lib (#6836)

This commit is contained in:
Pascal Fischer
2026-09-02 17:52:51 +02:00
committed by GitHub
parent 7b22d55bf6
commit 8a5e940c84
9 changed files with 111 additions and 84 deletions
+15
View File
@@ -1,5 +1,20 @@
package util
import (
"crypto/rand"
"math/big"
)
// RandIntn returns a uniformly distributed int in [0, n) sourced from
// crypto/rand. It panics if n <= 0 or the platform randomness source fails.
func RandIntn(n int) int {
v, err := rand.Int(rand.Reader, big.NewInt(int64(n)))
if err != nil {
panic(err)
}
return int(v.Int64())
}
// Difference returns the elements in `a` that aren't in `b`.
func Difference(a, b []string) []string {
mb := make(map[string]struct{}, len(b))