15. Interacting with the Go Runtime

One of the advantages of a dynamic language is that the internals of the implementation are exposed for your use. This lets you do various metaprogramming things that are much harder in static languages. The go package and its subpackages let you do very complex metaprogramming by transforming the abstract syntax tree of a Go program, but even without going that deep into the implementation there are lots of interesting things that you can do.

Finding the Type of a Variable

 8  switch t.Kind() { 9    case reflect.Int, reflect.Uint,10       reflect.Int8, reflect.Int16,11       reflect.Int32, reflect.Int64,12       reflect.Uint8, reflect.Uint16,13       reflect.Uint32, reflect.Uint64, ...

Get The Go Programming Language Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.