Change-Id: I401e6092b1cbbd332406ffa7f923c46de0a3ff49
GitHub-Last-Rev:
ef2057888465be3cff7fb60bc6ffe3d7573ec348
GitHub-Pull-Request: golang/go#71773
Reviewed-on: https://go-review.googlesource.com/c/go/+/650035
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
package rand_test
-import "crypto/rand"
+import (
+ "crypto/rand"
+ "fmt"
+ "math/big"
+)
+
+// ExampleInt prints a single cryptographically secure pseudorandom number between 0 and 99 inclusive.
+func ExampleInt() {
+ a, err := rand.Int(rand.Reader, big.NewInt(100))
+ if err != nil {
+ fmt.Println("error:", err)
+ return
+ }
+ fmt.Println(a.Int64())
+}
func ExampleRead() {
// Note that no error handling is necessary, as Read always succeeds.