Golang converting string to int64

No, there's no Atoi64. You should also pass in the 64 as the last parameter to ParseInt, or it might not produce the expected value on a 32-bit system.

Adding abbreviated example:

var s string = "9223372036854775807"
i, _ := strconv.ParseInt(s, 10, 64)
fmt.Printf("val: %v ; type: %[1]T\n", i)

https://play.golang.org/p/FUC8QO0-lYn


Parsing string into int64 example:

// Use the max value for signed 64 integer. http://golang.org/pkg/builtin/#int64
var s string = "9223372036854775807"
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
    panic(err)
}
fmt.Printf("Hello, %v with type %s!\n", i, reflect.TypeOf(i))

output:

Hello, 9223372036854775807 with type int64!

https://play.golang.org/p/XOKkE6WWer

Tags:

String

Int64

Go