2014-04-26 09:18:56 +00:00
|
|
|
package Tools
|
|
|
|
|
2014-10-19 17:19:11 +00:00
|
|
|
import (
|
2014-11-09 14:04:52 +00:00
|
|
|
"github.com/twinj/uuid"
|
2014-10-19 17:19:11 +00:00
|
|
|
"math/rand"
|
|
|
|
)
|
2014-04-26 09:18:56 +00:00
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Gets a random integer between 0 and max-1.
|
2014-04-26 09:18:56 +00:00
|
|
|
func RandomInteger(max int) (rnd int) {
|
|
|
|
rnd = rand.Intn(max)
|
|
|
|
return
|
|
|
|
}
|
2014-11-09 14:04:52 +00:00
|
|
|
|
2015-06-18 15:13:41 +00:00
|
|
|
// Gets a random 64 bit float between 0.0 and 1.0 (but without 1.0).
|
|
|
|
func RandomFloat64() (rnd float64) {
|
|
|
|
rnd = rand.Float64()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Gets a random UUID (v4).
|
2014-11-09 14:04:52 +00:00
|
|
|
func RandomGUID() (guidString string) {
|
|
|
|
guidString = uuid.NewV4().String()
|
|
|
|
return
|
|
|
|
}
|