Added the new and distributed NumGen, which replaces the old one. The old implementation was based on a master server.
26 lines
510 B
Go
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
|
|
}
|