Golang reflect.Kind type example

package reflect

Golang reflect.Kind type usage example

 package main

 import (
  "fmt"
  "reflect"
 )

 func main() {
  var anInteger int
  var varType reflect.Type = reflect.TypeOf(anInteger)

  fmt.Printf("anInteger is kind of %v and it is proven %v", varType.Kind(), varType.Kind() == reflect.Int)
 }

Output :

anInteger is kind of int and it is proven true

Reference :

http://golang.org/pkg/reflect/#Kind

Advertisement