packagemainimport("fmt""strconv")funcmain(){var orig string="ABC"// var an intvar newS string// var err error fmt.Printf("The size of ints is: %d\n", strconv.IntSize)// anInt, err = strconv.Atoi(origStr) an, err := strconv.Atoi(orig)if err !=nil{ fmt.Printf("orig %s is not an integer - exiting with error\n", orig)return} fmt.Printf("The integer is %d\n", an) an = an +5 newS = strconv.Itoa(an) fmt.Printf("The new string is: %s\n", newS)}
func mySqrt(f float64) (v float64, ok bool) {
if f < 0 { return } // error case
return math.Sqrt(f),true
}
func main() {
t := mySqrt(25.0)
fmt.Println(t)
}
t, ok := mySqrt(25.0)
if ok { fmt.Println(t) }
func atoi (s string) (n int) {
n, _ = strconv.Atoi(s)
return
}
count, err := fmt.Println(x) // number of bytes printed, nil or 0, error