mirror of
https://code.dnix.de/da/flokatirc
synced 2026-07-27 07:29:45 +02:00
Rework of module system.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user