Ocean/Tools/Random.go
Thorsten Sommer 81c4d15d9f Add the new NumGen
Added the new and distributed NumGen, which replaces the old one. The
old implementation was based on a master server.
2015-06-18 17:13:41 +02:00

26 lines
510 B
Go

package Tools
import (
"github.com/twinj/uuid"
"math/rand"
)
// Gets a random integer between 0 and max-1.
func RandomInteger(max int) (rnd int) {
rnd = rand.Intn(max)
return
}
// Gets a random 64 bit float between 0.0 and 1.0 (but without 1.0).
func RandomFloat64() (rnd float64) {
rnd = rand.Float64()
return
}
// Gets a random UUID (v4).
func RandomGUID() (guidString string) {
guidString = uuid.NewV4().String()
guidString = guidString[1 : len(guidString)-1]
return
}