ConvertArray 将[]string转为[]int
(arr []string)
| 32 | |
| 33 | //ConvertArray 将[]string转为[]int |
| 34 | func ConvertArray(arr []string) (bool, []int) { |
| 35 | result := make([]int, 0) |
| 36 | for _, i := range arr { |
| 37 | res, err := strconv.Atoi(i) |
| 38 | if err != nil { |
| 39 | return false, result |
| 40 | } |
| 41 | result = append(result, res) |
| 42 | } |
| 43 | return true, result |
| 44 | } |
| 45 | |
| 46 | //ValidateRemoteAddr 判断ip端口是否合法 |
| 47 | func ValidateRemoteAddr(ip string) bool { |