HomeToolsAbout

Kind

What is it

Go has a type reflection system, which allows for inspection of type at runtime.

  • This is made available through the reflect package
import ( "fmt" "reflect" ) func main() { var x int = 42 var y []string = []string{"hello", "world"} // Get the reflect.Type of x xType := reflect.TypeOf(x) fmt.Println("Type of x:", xType) fmt.Println("Kind of x:", xType.Kind()) // Output: Kind of x: int // Get the reflect.Type of y yType := reflect.TypeOf(y) fmt.Println("Type of y:", yType) fmt.Println("Kind of y:", yType.Kind()) // Output: Kind of y: slice }
AboutContact