最佳答案
如何在 Go 中检查字符串值是否为整数?
差不多
v := "4"
if isInt(v) {
fmt.Println("We have an int, we can safely cast this with strconv")
}
注意: 我知道 strconv.Atoi
返回一个错误,但是有没有其他函数可以做到这一点?
strconv.Atoi
的问题在于它将返回 7
作为 "a7"