From 6ea2acb5a3873dbec3721e79d1711e50e12fe9af Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 1 Apr 2022 18:26:38 +0200 Subject: Random works fine --- src/u_utils.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/u_utils.go') diff --git a/src/u_utils.go b/src/u_utils.go index b1d846f..4a81b85 100644 --- a/src/u_utils.go +++ b/src/u_utils.go @@ -39,13 +39,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/u_utils.go - * Wed Mar 30 01:25:20 CEST 2022 + * Fri Apr 1 18:25:20 CEST 2022 * Joe */ package main import ( + "math/rand" "time" "strconv" "strings" @@ -85,3 +86,14 @@ func get_time() [3]byte { func get_test_time() [3]byte { return seconds_to_time(time_to_seconds(get_time()) + 3) } + +func choose_file(options Options) int { + file_id := len(options.files) + if options.random == true && file_id > 1 { + rand.Seed(time.Now().UnixNano()) + file_id = rand.Intn(file_id) + } else { + file_id = 0 + } + return file_id +} -- cgit v1.2.3