diff --git a/kittens/icat/transmit.go b/kittens/icat/transmit.go index 25f83863a..7c2fde022 100644 --- a/kittens/icat/transmit.go +++ b/kittens/icat/transmit.go @@ -11,7 +11,7 @@ import ( "io" "kitty" "math" - not_rand "math/rand" + not_rand "math/rand/v2" "os" "path/filepath" "strings" diff --git a/tools/cmd/benchmark/main.go b/tools/cmd/benchmark/main.go index 5b1a12f1e..e9f836027 100644 --- a/tools/cmd/benchmark/main.go +++ b/tools/cmd/benchmark/main.go @@ -6,9 +6,8 @@ import ( "bytes" "errors" "fmt" - "math/rand" + "math/rand/v2" "strings" - "sync" "time" "kitty/tools/cli" @@ -114,16 +113,11 @@ func benchmark_data(description string, data string, opts Options) (duration tim return } -var rand_src = sync.OnceValue(func() *rand.Rand { - return rand.New(rand.NewSource(time.Now().UnixNano())) -}) - func random_string_of_bytes(n int, alphabet string) string { b := make([]byte, n) al := len(alphabet) - src := rand_src() for i := 0; i < n; i++ { - b[i] = alphabet[src.Intn(al)] + b[i] = alphabet[rand.IntN(al)] } return utils.UnsafeBytesToString(b) } @@ -158,13 +152,12 @@ func unicode() (r result, err error) { func ascii_with_csi() (r result, err error) { const sz = 1024*1024 + 17 out := make([]byte, 0, sz+48) - src := rand_src() chunk := "" for len(out) < sz { - q := src.Intn(100) + q := rand.IntN(100) switch { case (q < 10): - chunk = random_string_of_bytes(src.Intn(72)+1, ascii_printable) + chunk = random_string_of_bytes(rand.IntN(72)+1, ascii_printable) case (10 <= q && q < 30): chunk = "\x1b[m\x1b[?1h\x1b[H" case (30 <= q && q < 40): diff --git a/tools/utils/paths.go b/tools/utils/paths.go index 759177fcc..1705cd0f5 100644 --- a/tools/utils/paths.go +++ b/tools/utils/paths.go @@ -7,7 +7,7 @@ import ( "encoding/base32" "fmt" "io/fs" - not_rand "math/rand" + not_rand "math/rand/v2" "os" "os/exec" "os/user" @@ -137,7 +137,7 @@ var CacheDir = sync.OnceValue(func() (cache_dir string) { } candidate = filepath.Join(Expanduser(candidate), "kitty") } - os.MkdirAll(candidate, 0o755) + _ = os.MkdirAll(candidate, 0o755) return candidate })