A blog about programming, Web development, Open Source, Linux and DevOps.

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.

var i int = 25

var f float64 = float64(i) // Convert to float64
var u uint = uint(f)       // Convert to uint

Or inside a function:

i := 25

f := float64(i) // Convert to float64
u := uint(f)    // Convert to uint