package encoding
import "encoding"
encoding package defines for other packages may be used between the byte level and represents the converted text data interface. encoding / gob, encoding / json, encoding / xml three packages will be examined using these interfaces. Therefore, it implements these interfaces once, and can be used in multiple bag. Standard package and built-in types time.Time net.IP implement these interfaces. Interfaces are paired, respectively, and generating encoded data to restore.
Index
Home
type BinaryMarshaler
type BinaryMarshaler interface {
MarshalBinary() (data []byte, err error)
}
BinaryMarshaler type implements the interface itself can be serialized as binary format.
type BinaryUnmarshaler
type BinaryUnmarshaler interface {
UnmarshalBinary(data []byte) error
}
BinaryUnmarshaler type implements the interface itself may be solutions binary serialization format.
UnmarshalBinary decoded binary format of the data must be generated MarshalBinary. This function might be modified data content, so if you want to keep the data in the data in advance copy.
type TextMarshaler
type TextMarshaler interface {
MarshalText() (text []byte, err error)
}
BinaryMarshaler type implements the interface itself may be serialized as textual format utf-8 encoded.
type TextUnmarshaler
type TextUnmarshaler interface {
UnmarshalText(text []byte) error
}
TextUnmarshaler type implements the interface may be a textual format deserialized itself.
UnmarshalText textual format of the data must be decoded MarshalText generated. This function might be modified data content, so if you want to keep the data in the data in advance copy.