I Spy Code - GO

Type Conversions

The expression T(v) converts the value v to the type T.

Here are some golang examples that show how to do type conversions.

Source: (example.go)

package main
 
import (
   "fmt"
)
 
func main() {
 
   var i int = 42
   fmt.Printf("i:%v Type:%T \n",i,i)
 
   var f float64 = float64(i)
   fmt.Printf("f:%v Type:%T \n",f,f)
 
   var u uint = uint(i)
   fmt.Printf("u:%v Type:%T \n",u,u)
}
 

Output:

i:42 Type:int 
f:42 Type:float64 
u:42 Type:uint