From 56e74239d6b34df8f30ef046f0b0ff4ff0866a71 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sun, 14 Jun 2015 23:53:32 -0800 Subject: first commit --- utils/random.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 utils/random.go (limited to 'utils/random.go') diff --git a/utils/random.go b/utils/random.go new file mode 100644 index 000000000..ca2ace949 --- /dev/null +++ b/utils/random.go @@ -0,0 +1,20 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +package utils + +import ( + "math/rand" +) + +type Range struct { + Begin int + End int +} + +func RandIntFromRange(r Range) int { + if r.End-r.Begin <= 0 { + return r.Begin + } + return rand.Intn((r.End-r.Begin)+1) + r.Begin +} -- cgit v1.2.3-1-g7c22