Kind in Go
A Kind represents the specific kind of type that a Type represents. The zero Kind is not a valid kind.
package main
import (
"fmt"
"reflect"
)
func main() {
for _, v := range []interface{}{"hi", 42, func() {}} {
switch v := reflect.ValueOf(v); v.Kind() {
case reflect.String:
fmt.Println(v.String())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
fmt.Println(v.Int())
default:
fmt.Printf("unhandled kind %s", v.Kind())
}
}
}