- strconv.Atoi: Atoi returns the result of ParseInt(s, 10, 0) converted to type int.
- strconv.ParseInt: ParseInt interprets a string s in the given base (2 to 36) and returns the corresponding value i.
package mainimport ( "fmt" "strconv")func main() { str1 := "123" /** converting the str1 variable into an int using Atoi method */ i1, err := strconv.Atoi(str1) if err == nil { fmt.Println(i1) } str2 := "456" /** converting the str2 variable into an int using ParseInt method */ i2, err := strconv.ParseInt(str2, 10, 64) if err == nil { fmt.Println(i2) }}