2015-01-29 08:45:50 +00:00
|
|
|
|
# go-arbitrary
|
|
|
|
|
|
|
|
|
|
**go-arbitrary** is a Go library which provides tools for generating arbitrary data.
|
|
|
|
|
|
|
|
|
|
## Example
|
2021-11-21 14:17:30 +00:00
|
|
|
|
Here is a typical example:
|
|
|
|
|
```
|
|
|
|
|
// Generate an arbitrary phone‐number.
|
|
|
|
|
phoneNumber := arbitrary.PhoneNumber()
|
|
|
|
|
|
|
|
|
|
// Generate an arbitrary bool.
|
|
|
|
|
// Might be false, might be true.
|
|
|
|
|
bl := arbitrary.Bool()
|
|
|
|
|
|
|
|
|
|
// Generate an arbitrary string.
|
|
|
|
|
s := arbitrary.String()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Or if you want to provide your own souce of randomness:
|
2015-01-29 08:45:50 +00:00
|
|
|
|
```
|
|
|
|
|
src := rand.NewSource( time.Now().UTC().UnixNano() )
|
|
|
|
|
arb := arbitrary.New(src)
|
|
|
|
|
|
2021-11-21 14:17:30 +00:00
|
|
|
|
// Generate an arbitrary phone‐number.
|
|
|
|
|
phoneNumber := arb.PhoneNumber()
|
|
|
|
|
|
2015-01-29 08:45:50 +00:00
|
|
|
|
// Generate an arbitrary bool.
|
|
|
|
|
// Might be false, might be true.
|
|
|
|
|
bl := arb.Bool()
|
|
|
|
|
|
|
|
|
|
// Generate an arbitrary string.
|
|
|
|
|
s := arb.String()
|
|
|
|
|
```
|
2015-01-29 08:49:30 +00:00
|
|
|
|
## Documention
|
|
|
|
|
|
|
|
|
|
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-arbitrary
|
|
|
|
|
|
|
|
|
|
[![GoDoc](https://godoc.org/github.com/reiver/go-arbitrary?status.svg)](https://godoc.org/github.com/reiver/go-arbitrary)
|