import (
"fmt"
"encoding/gob"
"bytes"
)
type Size struct {
Height float32
Width float32
}
type Rect struct {
Size Size
}
var rect = Rect {
Size {5, 10},
}
//Encoding Binary Data
var buff bytes.Buffer
enc := gob.NewEncoder(&buff)
enc.Encode(rect)
var data_b = buff.Bytes()
//Decoding Binary Data
buff2 := bytes.NewBuffer(data_b)
rect2 := Rect{}
dec := gob.NewDecoder(buff2)
dec.Decode(&rect2)
//rect2 is {{5 10}}
fmt.Println("rect2 is", rect2)