Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hygull
Created December 8, 2016 23:59
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 hygull/7d7ea0dc03ab51fceb673d2e3bad989f to your computer and use it in GitHub Desktop.
Save hygull/7d7ea0dc03ab51fceb673d2e3bad989f to your computer and use it in GitHub Desktop.
strconv (convert a string to an int) created by hygull - https://repl.it/Eg5v/0
/*
@Date of creation : 05 Dec 2016.
@Aim of program : To convert a string of digits to an integer.
@Coded by : Rishikesh Agrawani.
*/
package main
import "fmt"
import "strconv"
func main(){
str:="1234"
//Printing the type of str
fmt.Printf("\n%T",str)
//Lets convert this string to an integer
n,err:=strconv.Atoi(str)
if err!=nil{
fmt.Println("You are not providing a valid string with digits")
}
fmt.Println("\nSuccessful conversion of a string to an integer")
fmt.Printf("%T",n)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment