docs(examples): add error handling to examples

This commit is contained in:
2021-12-17 01:25:25 +00:00
parent a86282e34d
commit 74dd8fb7e9
5 changed files with 126 additions and 51 deletions

View File

@@ -2,11 +2,16 @@ package rands_test
import (
"fmt"
"log"
"github.com/jimeh/rands"
)
func ExampleBytes() {
b, _ := rands.Bytes(8)
fmt.Printf("%+v\n", b) // => [0 220 137 243 135 204 34 63]
b, err := rands.Bytes(8)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", b) // => [181 153 143 235 241 20 208 173]
}