Standard library / encoding/gob
encoding/gob.Encoder
Stateful transmitter of values and type definitions. Calls may be concurrent, but do not assume ordering between independent goroutines. Expected stdout: '42\n'.
Formal Syntax & Structure
go syntaxgo
type Encoder struct { // Has unexported fields.}Working Example
Example Snippetgo
package main
import ( "bytes" "encoding/gob" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { var buf bytes.Buffer must(gob.NewEncoder(&buf).Encode(42)) var n int must(gob.NewDecoder(&buf).Decode(&n)) fmt.Println(n)}