Cover page by David Chisnall

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required