Rework of module system.

This commit is contained in:
Andreas Neue 2016-02-16 00:17:42 +01:00
parent 69e8ef85b1
commit ae56ff904c
12 changed files with 219 additions and 199 deletions

View file

@ -4,9 +4,25 @@ package util
import (
"bytes"
"math/rand"
"strconv"
"time"
)
func ToInt(v interface{}) int {
switch v.(type) {
case int:
return v.(int)
case float64:
return int(v.(float64))
case string:
ret, _ := strconv.Atoi(v.(string))
return ret
default:
return 0
}
}
func NumberToString(n int, sep rune) string {
start := 0
var buf bytes.Buffer
@ -31,3 +47,8 @@ func NumberToString(n int, sep rune) string {
}
return buf.String()
}
func Random(min, max int) int {
rand.Seed(time.Now().Unix())
return rand.Intn(max-min) + min
}