diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2022-04-01 18:26:38 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2022-04-01 18:26:38 +0200 |
commit | 6ea2acb5a3873dbec3721e79d1711e50e12fe9af (patch) | |
tree | d12a73c75672cfa405c47a05a97d96494507f163 /src/u_utils.go | |
parent | double 'p' fixed (diff) | |
download | go2work-6ea2acb5a3873dbec3721e79d1711e50e12fe9af.tar.gz go2work-6ea2acb5a3873dbec3721e79d1711e50e12fe9af.tar.bz2 go2work-6ea2acb5a3873dbec3721e79d1711e50e12fe9af.tar.xz go2work-6ea2acb5a3873dbec3721e79d1711e50e12fe9af.tar.zst go2work-6ea2acb5a3873dbec3721e79d1711e50e12fe9af.zip |
Random works fine
Diffstat (limited to '')
-rw-r--r-- | src/u_utils.go | 14 |
1 files changed, 13 insertions, 1 deletions
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 +} |