-
Notifications
You must be signed in to change notification settings - Fork 6
/
util.go
44 lines (38 loc) · 845 Bytes
/
util.go
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
41
42
43
44
package main
import (
"errors"
"strconv"
"strings"
)
func max(a int, b int) int {
if b > a {
return b
}
return a
}
func suffixToLength(s string, length int) string {
if len(s) < length {
diff := length - len(s)
return s + strings.Repeat(" ", diff)
}
return s
}
func parseFloat32(text string) float32 {
i64, _ := strconv.ParseFloat(text, 32)
return float32(i64)
}
func parseInt32(text string) int32 {
i64, _ := strconv.ParseInt(text, 10, 32)
return int32(i64)
}
func ensureModelIs30x(args *GlobalOptions, host string) error {
model, _, err := readTokenAndModel2GlobalOptions(args, host)
if err != nil {
return err
}
if !isModel30x(model) {
return errors.New("This command is not yet supported for your Netgear model. " +
"You might want to support the project by creating an issue on Github")
}
return nil
}