Go features a number of alternative encoding types other than JSON, TOML, and YAML. These are largely meant for transporting data between Go processes with things such as wire protocols and RPC, or in cases where some character formats are restricted.
This recipe will explore how to encode and decode the gob format and base64. The later chapters will explore protocols such as GRPC.
How to do it...
The following steps cover how to write and run your application:
- From your Terminal/console application,createa new directory called~/projects/go-programming-cookbook/chapter3/encoding.
- Navigate to this directory.
- Run the following command:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter3/encoding
You should see a file calledgo.modthat contains the following:
module github.com/PacktPublishing...