我想在golang中将字符串转换为整数.但我不知道字符串的格式.例如,"10"- > 10,"65.0"- > 65,"xx"- > 0,"11xx" - > 11,"xx11" - > 0
"10"
10
"65.0"
65
"xx"
0
我做了一些搜索并找到了strconv.ParseInt().但它无法处理"65.0".所以我必须检查字符串的格式.
strconv.ParseInt()
有没有更好的办法?
casting type-conversion go
casting ×1
go ×1
type-conversion ×1