codec

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package codec defines a config codec interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCodec is the base error of codec package.
	ErrCodec = errorex.New("codec")
	// ErrCodecNotRegistered is returned by Get if the requested Codec is not
	// registered.
	ErrCodecNotRegistered = ErrCodec.WrapFormat("codec '%s' not registered")
)

Functions

func Register

func Register(name string, codec Codec)

Register registers a Config codec under the specified name. It panics if the name is already registered.

Types

type Codec

type Codec interface {
	// Encode must encode interface to a byte slice or return an error.
	Encode(interface{}) ([]byte, error)
	// Decode must decode the byte slice to the interface or return an error.
	Decode([]byte, interface{}) error
}

Codec defines a configuration marshaling Codec interface.

func Get

func Get(name string) (Codec, error)

Get returns the codec registered under specified name and a nil error, if found. Otherwise a nil filter and an error.

Directories

Path Synopsis
Package gob implements a GOB Config Codec.
Package gob implements a GOB Config Codec.
Package json implements a JSON COnfog Codec.
Package json implements a JSON COnfog Codec.
Package xml is the XML Config Codec.
Package xml is the XML Config Codec.

Jump to

Keyboard shortcuts

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