You are previewing The Go Programming Language Phrasebook.

The Go Programming Language Phrasebook

Cover of The Go Programming Language Phrasebook by David Chisnall Published by Addison-Wesley Professional

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, ...

The best content for your career. Discover unlimited learning on demand for around $1/day.