Wednesday 1 May 2019

Go language: Print value and type of a variable


%v is used to print the value of a variable
%T is used to print the type of a variable.

App.go
package main

import "fmt"

func main() {
 var x int = 10

 fmt.Printf("i : %v, type : %T\n", x, x)
}

Output
i : 10, type : int



Previous                                                 Next                                                 Home

No comments:

Post a Comment