difference between encoding/gob and encoding/json

Gob is much more preferred when communicating between Go programs. However, gob is currently supported only in Go and, well, C, so only ever use that when you're sure no program written in any other programming language will try to decode the values.

When it comes to performance, at least on my machine, Gob outperforms JSON by a long shot. Test file (put in a folder on its own under your GOPATH)

$ go test -bench=.        
testing: warning: no tests to run
BenchmarkGobEncoding-4           1000000              1172 ns/op
BenchmarkJSONEncoding-4           500000              2322 ns/op
BenchmarkGobDecoding-4           5000000               486 ns/op
BenchmarkJSONDecoding-4           500000              3228 ns/op
PASS
ok      testencoding    6.814s

Package encoding/gob is basically Go specific and unusable with other languages but it is very efficient (fast and generates small data) and can properly marshal and unmarshal more data structures. Interfacing with other tools is often easier via JSON.