In this chapter, we explored the encoding methods offered by the Go standard package and third-party libraries. They can be divided into two main categories. The first is the textual-based encoding methods, which are easy to read and write for both human and machines. However, they have more overhead and tend to be much slower than their counterpart, binary-based encoding. Binary-based encoding methods have little overhead but are not human readable.
In text-based encoding, we find JSON, XML, and YAML. The first two are handled by the standard library, the last needs an external dependency. We explored how Go allows us to specify structure tags to change the default encoding and decoding behaviors, and how to use these tags in these operations. Then, we checked and implemented the interfaces that define custom behavior during the marshal and unmarshal operations....