Blame view
int_util.go
753 Bytes
18fcd6d6b merged with util ... |
1 |
package webutility |
cacf57bd4 merging with /uti... |
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 |
import ( "fmt" "strconv" ) // ClampInt64 ... func ClampInt64(v, min, max int64) int64 { if v < min { return min } else if v > max { return max } return v } // InRangeInt64 ... func InRangeInt64(v, min, max int64) bool { return (v >= min && v <= max) } // StringToInt64 ... func StringToInt64(s string) int64 { i, _ := strconv.ParseInt(s, 10, 64) return i } |
e9419e37d string to float |
29 30 31 32 33 |
// StringToFloat64 ... func StringToFloat64(s string) float64 { f, _ := strconv.ParseFloat(s, 64) return f } |
cacf57bd4 merging with /uti... |
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
// Int64ToString ... func Int64ToString(i int64) string { return fmt.Sprintf("%d", i) } // BoolToInt64 ... func BoolToInt64(b bool) int64 { if b { return 1 } return 0 } // Int64ToBool ... func Int64ToBool(i int64) bool { return i != 0 } |