package main import ( "fmt" "reflect" ) func main() { var num int = 5 var f float64 = 5.6 var str string = "Hello" fmt.Println(reflect.TypeOf(num).Kind()) // Outputs: int fmt.Println(reflect.TypeOf(f).Kind()) // Outputs: float64 fmt.Println(reflect.TypeOf(str).Kind()) // Outputs: string }
package main import ( "fmt" "reflect" ) func main() { var num int = 5 var arr [5]int var slice []int var str string = "Hello" fmt.Println(reflect.ValueOf(num).Kind() == reflect.Int) // Outputs: true fmt.Println(reflect.ValueOf(arr).Kind() == reflect.Array) // Outputs: true fmt.Println(reflect.ValueOf(slice).Kind() == reflect.Slice) // Outputs: true fmt.Println(reflect.ValueOf(str).Kind() == reflect.String) // Outputs: true }In the above examples, we use the reflect package to determine the kind of various types of values such as int, float, string, array, and slice. Package Library: The reflect package is part of the standard library in Go and does not require any package installation.