Skip to content

Instantly share code, notes, and snippets.

@irshadhasmat
Created May 29, 2018 05:45
Embed
What would you like to do?
GoLang : String to Int Conversion
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