Skip to content

Instantly share code, notes, and snippets.

@taichi
Created February 5, 2014 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taichi/8820141 to your computer and use it in GitHub Desktop.
Save taichi/8820141 to your computer and use it in GitHub Desktop.
import (
"crypto/rand"
"strings"
)
func FixSeed(seed string, fn func()) func() {
return func() {
orig := rand.Reader
rand.Reader = strings.NewReader(seed) // fix seed
defer func() {
rand.Reader = orig
}()
fn()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment