Created
May 29, 2018 05:45
-
-
Save irshadhasmat/b81ddb7a03fd042655422e77c721df4f to your computer and use it in GitHub Desktop.
GoLang : String to Int 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 Int conversation => strconv.Atoi function return integer with error if any. | |
// Atoi means "A" String to "i" integer | |
intI, err := strconv.Atoi(str) | |
if err == nil{ | |
fmt.Println(intI) | |
}else{ | |
fmt.Println(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment