mirror of
https://github.com/jimeh/rands.git
synced 2026-02-19 11:26:38 +00:00
feat(randsmust): add randsmust package
randsmust is specifically intended as an alternative to rands for use in tests. All functions return a single value, and panic in the event of an error. This makes them easy to use when building structs in test cases that need random data. Internally the package simply calls the equivalent function from the rands package, and panics if a error is returned.
This commit is contained in:
12
randsmust/bytes_example_test.go
Normal file
12
randsmust/bytes_example_test.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package randsmust_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jimeh/rands/randsmust"
|
||||
)
|
||||
|
||||
func ExampleBytes() {
|
||||
b := randsmust.Bytes(8)
|
||||
fmt.Printf("%+v\n", b) // => [6 99 106 54 163 188 28 152]
|
||||
}
|
||||
Reference in New Issue
Block a user