encoding

package
v2.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(codec Codec)

Register registers a codec.

Types

type Appender added in v2.6.5

type Appender interface {
	// Append appends the encoding of v to dst.
	Append(dst []byte, v any) ([]byte, error)
}

Appender is an optional interface implemented by codecs that can append an encoded value to dst. It lets callers encode directly into a pooled buffer. Implementations may reallocate dst when its capacity is insufficient; callers detect that by comparing the returned length with the original capacity.

type Codec

type Codec interface {
	// Name returns the codec type.
	Name() string
	// Marshal encodes v.
	Marshal(v any) ([]byte, error)
	// Unmarshal decodes data into v.
	Unmarshal(data []byte, v any) error
}

func Invoke

func Invoke(name string) Codec

Invoke returns the codec registered under name, panicking when it is not registered.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL