Type Conversion
Go never converts types implicitly. Write T(value) and use strconv for strings.
Example
package main
import (
"fmt"
"strconv"
)
func main() {
i := 7
f := float64(i) / 2
n, _ := strconv.Atoi("42")
fmt.Println(f, n+1, strconv.Itoa(99)+"!")
}Result
3.5 43 99!
Exercise
Convert to float.
(i)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.