Structure tags and basic reflection in Go

Reflection is a complicated topic that can't really be covered in a single recipe; however, a practical application of reflection is dealing with structure tags. At their core, struct tags are just key–value strings: you look up the key, then deal with the value. As you can imagine, for something like JSON marshaling and unmarshaling, there's a lot of complexity for dealing with these values.

The reflect package is designed for interrogating and understanding interface objects. It has helper methods to look at the different kinds of structures, values, struct tags, and more. If you need something beyond the basic interface conversion, such as the one at the beginning of this chapter, this is the package you should look at.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.107.90