package main import "fmt" func main() { var name string = "Mahesh" age := 25 price := 300.40 fmt.Printf("%T %v\n",name,name) fmt.Printf("%T %v\n",age,age) fmt.Printf("%T %v\n",price,price) } Output string Mahesh int 25 float64 300.4 Explanation In the above program snippet, we use Printf() function of fmt package to print the formatted output. Withing the Printf( ) %T and %v is called format specifier which represents the output format. %T represents the Type, which prints the variable type %v represents the variable's value. age := 25 , creates a variable age with the short variable declaration and assign the value 25. In this case, the variable automatically receives the type and here age is the type of int. price:=300.40, In this statement price, is created of type float64 because float64 is the default type of floating values in go lang. To create a float32 ty...
Comments