forked from redcode-labs/Coldfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrappers.go
More file actions
40 lines (33 loc) · 847 Bytes
/
wrappers.go
File metadata and controls
40 lines (33 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package coldfire
import (
"fmt"
"math/rand"
"strconv"
"time"
)
// F is a wrapper for the Sprintf function.
func F(str string, arg ...interface{}) string {
return fmt.Sprintf(str, arg...)
}
func f(s string, arg ...interface{}) string {
return fmt.Sprintf(s, arg...)
}
// F is a wrapper for the Println function.
func P() {
fmt.Println()
}
// Str2Int converts a string into an integer.
func Str2Int(string_integer string) int {
// i, _ := strconv.ParseInt(string_integer, 10, 32)
i, _ := strconv.Atoi(string_integer)
return i
}
// IntToStr converts an integer into a string.
func Int2Str(i int) string {
return strconv.Itoa(i)
}
// RandomInt returns an integer within a given range.
func RandomInt(min int, max int) int {
rand.Seed(time.Now().UnixNano())
return rand.Intn(max-min) + min
}