diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-19 13:50:05 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-19 13:50:05 -0700 |
commit | ea078f9b4221332b9f63cc4e178aa814eec06e4f (patch) | |
tree | a90da6f77f265ce63c82da73f502f324bfb89ebc /cmd/ponzu/vendor/github.com/nilslice/rand | |
parent | ea8ea4c22662aa082181a6c456ec56acf2bd777c (diff) |
vendoring all the dependencies into vendor directory prior to build step, which still vendors ponzu core code
Diffstat (limited to 'cmd/ponzu/vendor/github.com/nilslice/rand')
-rw-r--r-- | cmd/ponzu/vendor/github.com/nilslice/rand/README.md | 2 | ||||
-rw-r--r-- | cmd/ponzu/vendor/github.com/nilslice/rand/rand.go | 38 |
2 files changed, 40 insertions, 0 deletions
diff --git a/cmd/ponzu/vendor/github.com/nilslice/rand/README.md b/cmd/ponzu/vendor/github.com/nilslice/rand/README.md new file mode 100644 index 0000000..89cc36d --- /dev/null +++ b/cmd/ponzu/vendor/github.com/nilslice/rand/README.md @@ -0,0 +1,2 @@ +rand provides a convenient package to use crypto/rand as default +but falls back to math/rand if necessary
\ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/nilslice/rand/rand.go b/cmd/ponzu/vendor/github.com/nilslice/rand/rand.go new file mode 100644 index 0000000..cbff54a --- /dev/null +++ b/cmd/ponzu/vendor/github.com/nilslice/rand/rand.go @@ -0,0 +1,38 @@ +// rand provides a convenient package to use crypto/rand as default +// but falls back to math/rand if necessary +package rand + +import ( + crand "crypto/rand" + mrand "math/rand" + "time" +) + +var g_mathRand = mrand.New(mrand.NewSource(time.Now().Unix())) + +// Read fills the slice with random bytes +func Read(xs []byte) { + length := len(xs) + n, err := crand.Read(xs) + if n != length || err != nil { + for length > 0 { + length-- + xs[length] = byte(g_mathRand.Int31n(256)) + } + } +} + +// Int63 returns a non-negative 63-bit integer as an int64 +func Int63() int64 { + xs := make([]byte, 8) + var n int64 + + Read(xs) + xs[0] &= 0x7F + for _, x := range xs { + n <<= 4 + n |= int64(x) + } + + return n +} |