I want to convert a string to an int64. What I find from the strconv
package is the Atoi
function. It seems to cast a string to an int and return it:
// Atoi is shorthand for ParseInt(s, 10, 0).
func Atoi(s string) (i int, err error) {
i64, err := ParseInt(s, 10, 0)
return int(i64), err
}
The ParseInt actually returns an int64:
func ParseInt(s string, base int, bitSize int) (i int64, err error){
//...
}
So if I want to get an int64 from a string, should I avoid using Atoi, instead use ParseInt? Or is there an Atio64 hidden somewhere?