The doc says. https://github.com/golang/go/blob/d6c4583ad4923533ddc9f5792ed3b66f3b9f9feb/src/encoding/gob/doc.go#L178 If a value is passed to Encode and the type is not a struct (or pointer to struct, etc.), for simplicity of processing it is represented as a struct of one field. The only visible effect of this is to *encode a zero byte after the value*, just as after the last field of an encoded struct.
But here says, https://github.com/golang/go/blob/d6c4583ad4923533ddc9f5792ed3b66f3b9f9feb/src/encoding/gob/doc.go#L402 A single non-struct value at top level is transmitted *like a field with* *delta tag 0*. For instance, a signed integer with value 3 presented as the argument to Encode will emit: 03 04 00 06 Which represents: 03 // this value is 3 bytes long 04 // the type number, 2, represents an integer 00 // tag delta 0 06 // value 3 It seems the later one is correct? Related issue encoding/gob: encoding of single values doesn't agree with documentation <https://github.com/golang/go/issues/16978> -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ea0ef422-1289-4341-ad32-d4a8c2d023d4n%40googlegroups.com.