How can I check if a string value is an integer or not in Golang?
Something like
v := "4"
if isInt(v) {
fmt.Println("We have an int, we can safely cast this with strconv")
}
Note: I know that strconv.Atoi
returns an error, but is there any other function to do this?
The problem with strconv.Atoi
is that it will return 7
for "a7"