Right now I am doing the following in order to parse an integer from a string and then convert it to int type:
tmpValue, _ := strconv.ParseInt(str, 10, 64) //returns int64
finalValue = int(tmpValue)
It is quite verbose, and definitely not pretty, since I haven’t found a way to do the conversion in the ParseInt call. Is there a nicer way to do that?
It seems that the function
strconv.Atoidoes what you want, except that it works regardless of the bit size ofint(your code seems to assume it’s 64 bits wide).