skip to content

Non-JSON Wire Formats

Encoding that is not JSON: encoding/xml attributes and character data, encoding/csv quoting, encoding/binary byte order, gob, base64 and hex. Each has a trap that quietly corrupts data.

part ofGo (Golang)overview, primer and where to startread it →
on this pageshow

explore

questions

page 2 of 2

A Go import sets csv.Reader.ReuseRecord = true and keeps every record; why do all rows end up identical?

level: seniorimportance: nice to knowfreq 28%

basics

~20 s

With ReuseRecord set, Read may return a slice sharing the previous call's backing array, so every retained row points at that one array and shows whatever the last record left in it. Copy each record you intend to keep.

open as a page

Two Go services share a gob cache file; which struct changes on one side break the other's decode?

level: seniorimportance: nice to knowfreq 24%

basics

~20 s

Adding or removing an exported field is tolerated: gob matches fields by name, discards unknown ones and leaves missing ones untouched. Renames silently lose data, incompatible type changes fail at decode, and relocating a registered type breaks interface-typed fields.

open as a page

showing 31–32 of 32