Type conversion means changing a value's data type. Java supports both explicit type conversion and implicit type conversion, but Go supports only explicit type conversion.
The type conversion syntax converts the value val to type T, as shown below.
T(val)
In the example, an int value is converted to the float64 and uint32 types.
func Example_TypeConversion() {
var i = 52
var j float64 = float64(i)
var k = uint32(j)
fmt.Println(i)
fmt.Println(j)
fmt.Println(k)
//Output:
//52
//52
//52
}
You can find the code written in this post on github.
References
- Go type conversion
- Java type conversion