소스 검색

codec: Document that the first set of bytes of any value MUST NOT represent nil.

Fixes #230
Ugorji Nwoke 8 년 전
부모
커밋
d2b24cf3d3
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      codec/helper.go

+ 4 - 0
codec/helper.go

@@ -391,6 +391,10 @@ var immutableKindsSet = [32]bool{
 // Any type which implements Selfer will be able to encode or decode itself.
 // Any type which implements Selfer will be able to encode or decode itself.
 // Consequently, during (en|de)code, this takes precedence over
 // Consequently, during (en|de)code, this takes precedence over
 // (text|binary)(M|Unm)arshal or extension support.
 // (text|binary)(M|Unm)arshal or extension support.
+//
+// Note: *the first set of bytes of any value MUST NOT represent nil in the format*.
+// This is because, during each decode, we first check the the next set of bytes
+// represent nil, and if so, we just set the value to nil.
 type Selfer interface {
 type Selfer interface {
 	CodecEncodeSelf(*Encoder)
 	CodecEncodeSelf(*Encoder)
 	CodecDecodeSelf(*Decoder)
 	CodecDecodeSelf(*Decoder)