package main import ( "fmt" "reflect" ) func main() { var a int = 10 fmt.Println(reflect.TypeOf(a).Kind()) var b string = "Hi there!" fmt.Println(reflect.TypeOf(b).Kind()) } // Output: // int // string
package main import ( "fmt" "reflect" ) func main() { var a interface{} = [3]int{1, 2, 3} t := reflect.TypeOf(a) if t.Kind() == reflect.Array || t.Kind() == reflect.Slice { fmt.Println("It is a slice or array.") } } // Output: It is a slice or array.This code asserts that the type of variable "a" satisfies both array and slice structures, returning a boolean value that prints "It is a slice or array." While go.types Type Kind does not represent an independent package, see the go documentation section for detailed information: https://golang.org/pkg/reflect/#Kind.