Standard library / reflect
reflect.Type
Descriptor for a Go type. Type equality means identical Go types; String is not a unique identifier. Kind-specific methods can panic. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
type Type interface {
Align() int
FieldAlign() int
Method(int) Method
MethodByName(string) (Method, bool)
NumMethod() int
Name() string
PkgPath() string
Size() uintptr
String() string
Kind() Kind
Implements(u Type) bool
AssignableTo(u Type) bool
ConvertibleTo(u Type) bool
Comparable() bool
Bits() int
ChanDir() ChanDir
IsVariadic() bool
Elem() Type
Field(i int) StructField
FieldByIndex(index []int) StructField
FieldByName(name string) (StructField, bool)
FieldByNameFunc(match func(string) bool) (StructField, bool)
In(i int) Type
Key() Type
Len() int
NumField() int
NumIn() int
NumOut() int
Out(i int) Type
OverflowComplex(x complex128) bool
OverflowFloat(x float64) bool
OverflowInt(x int64) bool
OverflowUint(x uint64) bool
CanSeq() bool
CanSeq2() bool
}Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { type Count int a := reflect.TypeOf(Count(0)) b := reflect.TypeOf(0) fmt.Println(a.Kind() == b.Kind(), a == b)}