import (
"fmt"
"encoding/gob"
"bytes"
)
var dic = map[int]string{
1: "one",
2: "two",
}
//Encoding Binary Data
var buff bytes.Buffer
enc := gob.NewEncoder(&buff)
enc.Encode(dic)
var data_b = buff.Bytes()
//Decoding Binary Data
buff2 := bytes.NewBuffer(data_b)
dic2 := map[int]string{}
dec := gob.NewDecoder(buff2)
dec.Decode(&dic2)
//dic2 is map[1:one 2:two]
fmt.Println("dic2 is", dic2)