Skip to content

Instantly share code, notes, and snippets.

@joshheinrichs
Created August 1, 2016 20:06
Show Gist options
  • Save joshheinrichs/59cd6c6f5eabb8c4d3f8b2efbe88697c to your computer and use it in GitHub Desktop.
Save joshheinrichs/59cd6c6f5eabb8c4d3f8b2efbe88697c to your computer and use it in GitHub Desktop.
Since Go's math/rand package does not implement Uint64, this shows a simple way to add it yourself.
package main
import (
"fmt"
"math/rand"
)
// Uint64 returns a pseudo-random 64-bit value as a uint64
// from the default Source.
func Uint64() uint64 {
return uint64(rand.Uint32())<<32 | uint64(rand.Uint32())
}
func main() {
fmt.Printf("%b\n", Uint64())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment