Last Updated: May 22, 2026
JSON is the right answer when two different systems need to talk to each other, but a lot of the time both ends of a wire (or a file) are written in Go. In that case JSON pays a cost it does not need to pay: every value is encoded as text, every number is reparsed, every field name is repeated. The encoding/gob package is Go's answer to "what if both sides know they are Go?" It is a self-describing binary format designed by the Go authors specifically for Go-to-Go communication, with first-class support for Go's type system. This lesson covers when to choose gob over JSON, how the encoder and decoder work, how to handle interfaces, custom encoding hooks, and the pitfalls that show up in production.