convert variable from int to float in Go
Code snippet on how to convert variable from int to float in Go
// declare and assign a variable of type int
x := 5
// convert int to float
y := float64(x)
This code snippet shows how to convert a variable of type int to type float64 in the Go programming language. First, we declare and assign the variable x with a value of 5, which is a variable of type int. Then, to convert the int variable to a float64 variable, we use a built-in Go function - float64() - and pass our variable x as an argument. This function then converts the int to a float, and stores the float in a variable called y.