Last active
August 28, 2017 03:12
-
-
Save morrxy/c982e8d28f1fb5ce8e3cc394add546c6 to your computer and use it in GitHub Desktop.
[str to int] #golang
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
| //https://www.dotnetperls.com/parseint-go | |
| package main | |
| import ( | |
| "fmt" | |
| "strconv" | |
| ) | |
| func main() { | |
| value := "123" | |
| // Convert string to int. | |
| number, _ := strconv.ParseInt(value, 10, 0) | |
| // We now have an int. | |
| fmt.Println(number) | |
| if number == 123 { | |
| fmt.Println(true) | |
| } | |
| } | |
| //Output | |
| //123 | |
| //true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment