From 9f619d29dccd26256957459b584164f0639eba09 Mon Sep 17 00:00:00 2001 From: Jrohy Date: Thu, 5 Mar 2020 21:41:08 +0800 Subject: [PATCH] . --- util/string.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/string.go b/util/string.go index 39ca7faf..0168fa7a 100644 --- a/util/string.go +++ b/util/string.go @@ -28,8 +28,8 @@ const ( RESET = "\033[0m" ) -// IsNumber 判断字符串是否为数字 -func IsNumber(input string) bool { +// IsInteger 判断字符串是否为整数 +func IsInteger(input string) bool { _, err := strconv.Atoi(input) return err == nil } @@ -83,7 +83,7 @@ func LoopInput(tip string, choices interface{}, print bool) int { } if inputString == "" { return -1 - } else if !IsNumber(inputString) { + } else if !IsInteger(inputString) { fmt.Println("输入有误,请重新输入") continue }