Go - Type Conversions
In Go assignments between items of different types require an explicit conversion.
Type conversions are performed using the expression T(v)
which converts the value v
to the type T
.
go
var i int = 25var f float64 = float64(i) // Convert to float64var u uint = uint(f) // Convert to uint
Or inside a function:
go
i := 25f := float64(i) // Convert to float64u := uint(f) // Convert to uint