Type Conversion and Type Assertion in Go
Type conversion The expression T(v) converts the value v to the type T.
In Go, assignment between items of different type requires an explicit conversion.
Here’s an example.
1 2 3 4 5 6 7 8 9 10 11 12 13 package main import ( "fmt" "math" ) func main() { var x, y int = 11, 12 f := math.Sqrt(float64(x*x + y*y)) var z uint = uint(f) fmt.Println(x, y, z) } Type assertion Type assertion provides access to an interface value’s underlying concrete value.