Hi, all

I find that gob encoding ignores fields when they have zero values.

package main

import (
        "bytes"
        "encoding/gob"
)

type Type struct {
        Data uint32
}

func main() {
        var t Type
        buffer := bytes.NewBuffer(nil)
        encoder := gob.NewEncoder(buffer)
        encoder.Encode(t)
        decoder := gob.NewDecoder(buffer)
        t.Data = 123
        decoder.Decode(&t)
        println(t.Data)
}

I expect this example output is 0, but 123 found.

I wonder if this is a bug or an feature?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to