I have a Go program that I simply want to convert a string to an int. I understand the function:
val, err := strconv.Atoi(myValueAsAString)
works and I can check the error by the following:
if err != nil {
//handle error
}
But what if I am 100% the string will be a number, and I want to convert it to an int in an if statement, like the following:
if 45 + strconv.Atoi(value) >= 90 {
//do something
}
But strconv.Atoi also returns an error value as well, so how can I throw that away and essentially do what I did above, without having to define the variable above the if statement and use it in the if statement. I'm not sure if this is possible or not, but I would love to know.