Go encoding/gob: self-describing binary values
Answer: This package moves self-describing binary values, called gobs, between a transmitter and a receiver.
Streams of gobs
The transmitter is an Encoder; the receiver is a Decoder.
A common use is carrying arguments and results for remote procedure calls.
Each item is preceded by a type specification, so the stream describes itself.
Those types are expressed with a small set of predefined types.
Pointers and recursion
A pointer is not sent; the value it points to is sent instead.
That is, the values are flattened.
A nil pointer is rejected, because it has no value to send.
Recursive types are fine, but cyclic data is problematic.
See also
Claims
- id: C1 claim: Gobs are binary values exchanged between an Encoder and a Decoder. source: S1 evidence: "binary values exchanged between an Encoder"
- id: C2 claim: A gob stream is self-describing. source: S1 evidence: "A stream of gobs is self-describing."
- id: C3 claim: Pointers themselves are not sent; the pointed-to values are. source: S2 evidence: "Pointers are not transmitted, but the things they point to are"
- id: C4 claim: Nil pointers are not permitted. source: S2 evidence: "Nil pointers are not permitted,"
Sources
- [S1] encoding/gob package reference. Go. https://pkg.go.dev/encoding/gob . License: BSD-3-Clause. Accessed 2026-11-23.
- [S2] encoding/gob source. Go. https://go.dev/src/encoding/gob/doc.go . License: BSD-3-Clause. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, encoding/gob package reference; Go, encoding/gob source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Go, encoding/gob package reference; Go, encoding/gob source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go encoding/gob: self-describing binary values." iinventedlight Library, iil:note:j39yt44z, version of 2026-11-23. https://iinventedlight.com/library/notes/go-encoding-gob/. License: CC-BY-4.0.
@misc{iil_note_j39yt44z,
author = {{iinventedlight}},
title = {{Go encoding/gob: self-describing binary values}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/go-encoding-gob/},
note = {Permanent ID iil:note:j39yt44z. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-encoding-gob.schema.json (schema; CC-BY-4.0)
- go-encoding-gob.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-encoding-gob.md.