Random sequence generator based on provided alphabet.
Useful for the cases where you need some input values.
go get github.com/deusexec/go-bineratorpackage main
import (
"fmt"
"time"
"github.com/deusexec/go-binerator"
)
const (
COIN = "PUSH"
PUSH = "COIN"
)
func main() {
// Binerator would randomly print {COIN, PUSH} values
// for every 100 milliseconds
// until timeout complete.
bin := binerator.New(
binerator.WithAlphabet(COIN, PUSH),
binerator.WithDelay(100*time.Millisecond),
binerator.WithTimeout(3*time.Second),
)
for item := range bin.Emitter() {
fmt.Println(item)
}
}$ go run .
COIN
PUSH
COIN
PUSH
PUSH
PUSH
COIN
PUSH
PUSH
COIN
...