Skip to content

Instantly share code, notes, and snippets.

@irshadhasmat
Created May 29, 2018 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irshadhasmat/b81ddb7a03fd042655422e77c721df4f to your computer and use it in GitHub Desktop.
Save irshadhasmat/b81ddb7a03fd042655422e77c721df4f to your computer and use it in GitHub Desktop.
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