Skip to content

Instantly share code, notes, and snippets.

@paddycarver
Last active December 15, 2015 02:39
Show Gist options
  • Save paddycarver/5188869 to your computer and use it in GitHub Desktop.
Save paddycarver/5188869 to your computer and use it in GitHub Desktop.
Hey, I just met you, and this is crazy, but here's a random number, it may ask you to call me.
package main
import (
"crypto/rand"
"fmt"
"math/big"
)
type action func(bool)
func callMe(flag bool) {
if flag {
fmt.Println("Hey, I just met you")
fmt.Println("And this is crazy")
fmt.Println("But here's my number")
fmt.Println("So call me, maybe?")
}
}
func maybe(a action) {
bigint, err := rand.Int(rand.Reader, big.NewInt(100))
if err != nil {
panic(err)
}
i := bigint.Int64()
a(i % 4 == 0)
}
func main() {
maybe(callMe)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment