« Back to home

Reflection in Go and modifying struct values

Recently I found myself wanting to write some code to load values into a Go object. The obvious approach is reflection. However, the Go documentation on reflection is somewhat impenetrable, and the accompanying article on The Laws of Reflection only has a single skimpy example involving structs right at the end. After some trial and error I came up with some robust code to demonstrate examining a struct and altering its fields.…

Read more »