WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Go Type casting


Type conversion is used to convert a variable of one data type to another. The basic format of the Go language type conversion is as follows:

type_name(expression)

type_name is a type and expression is an expression.

example

In the following example, the integer is converted to a float, and the result is evaluated, and the result is assigned to a floating-point variable:

example

package main

import "fmt"

func main() {
   var sum int = 17
   var count int = 5
   var mean float32
   
   mean = float32(sum)/float32(count)
   fmt.Printf("mean Value: %f\n",mean)
}

The above example execution output is:

mean The value is: 3.400000