Documentation ¶
Overview ¶
Package encoding is a wrapper for the core functionality of packages like "encoding/json" and "encoding/gob".
It contains the Codec interface and multiple implementations for encoding Go values to other formats and decode from other formats to Go values. Formats can be JSON, gob etc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // JSON is a JSONcodec that encodes/decodes Go values to/from JSON. JSON = JSONcodec{} // Gob is a GobCodec that encodes/decodes Go values to/from gob. Gob = GobCodec{} )
Convenience variables
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec interface { // Marshal encodes a Go value to a slice of bytes. Marshal(v any) ([]byte, error) // Unmarshal decodes a slice of bytes into a Go value. Unmarshal(data []byte, v any) error }
Codec encodes/decodes Go values to/from slices of bytes.
type GobCodec ¶
type GobCodec struct{}
GobCodec encodes/decodes Go values to/from gob. You can use encoding.Gob instead of creating an instance of this struct.
Click to show internal directories.
Click to hide internal directories.