« Back to Index

Go: return a sample (random bool) based on percentage

View original Gist on GitHub

Tags: #go

sample.go

// sample returns True randomly at a percentage of the time
func sample(percent int) bool {
	return rand.Intn(100) < percent
}