GoLang : String to Int64 Conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strconv" | |
) | |
func main() { | |
str := "12345" | |
// String to Int64 conversation => strconv.ParseInt function return int64 with error if any. | |
// strconv.ParseInt() => function convert string to int64 | |
int64I, err := strconv.ParseInt(str, 10, 64) | |
if err == nil{ | |
fmt.Println(int64I) | |
}else{ | |
fmt.Println(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment