package main import ( "fmt" "strconv" ) func main() { str := "12345.6789" fmt.Printf("Parsing %s\n", str) aa,err := strconv.ParseFloat(str, 32) if err==nil { fmt.Printf("The string parsed into a 32bit float %f\n", aa); aa64,err := strconv.ParseFloat(str, 64) if err==nil { fmt.Printf("The string parsed into a 64bit float %f\n", aa64); } aaI,errI := strconv.ParseInt(str, 10, 32) if errI==nil { fmt.Printf("The string parsed into an int %d\n", aaI); } else { fmt.Printf("The string could not be parsed into an int\n") } aaI,errI = strconv.ParseInt("12345", 10, 32) if errI==nil { fmt.Printf("The string 12345 parsed into an int %d\n", aaI); } else { fmt.Printf("The string could not be parsed into an int\n") } } }