Type casting is the explicit conversion of a value from one compatible type to another.
newValue := targetType(value)
Go does not allow implicit conversions. This prevents hidden bugs and keeps behavior predictable.
a := 5.6 // float64b := 10 // intc := a + b // <-- compiler: invalid operation: a + b (mismatched types float64 and int)c := a + float64(b) // 15.6 (float64)
Casting from float to integer removes (cuts off) the decimal part: