v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/fastrand/example_rng_test.go (about) 1 package fastrand_test 2 3 import ( 4 "fmt" 5 6 "v8.run/go/exp/fastrand" 7 ) 8 9 func Example_rNG() { 10 rng := fastrand.AcquireRNG() 11 defer fastrand.ReleaseRNG(rng) 12 13 rng.SetSeed(42) 14 15 fmt.Printf("Number between 0 and 10: %d\n", rng.Int63n(10)) 16 fmt.Printf("Number between 0 and 100: %d\n", rng.Int63n(100)) 17 fmt.Printf("Number between 0 and 1000: %d\n", rng.Int63n(1000)) 18 fmt.Printf("64-bit unsigned integer: %d\n", rng.Uint64()) 19 20 // Output: Number between 0 and 10: 4 21 // Number between 0 and 100: 67 22 // Number between 0 and 1000: 496 23 // 64-bit unsigned integer: 16395596082725179435 24 }