Created
May 29, 2018 05:56
-
-
Save irshadhasmat/f8f317d00794310504a87515f2dc9d7b to your computer and use it in GitHub Desktop.
GoLang : String to Int64 Conversion
This file contains hidden or 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