codec

package module
v0.0.0-...-fa3f3c9 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 3 Imported by: 1

README

codec

codec

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(b []byte, v interface{}) error

Decode implate Decoder interface

func Encode

func Encode(v interface{}) ([]byte, error)

Encode xx

func Format

func Format(dest, src interface{}) error

Format implate Formater interface

Types

type Codec

type Codec interface {
	Encoder
	Decoder
	Formatter
}

Codec encode/decode interface

func New

func New(kinds ...string) Codec

New codec factory

type Decoder

type Decoder interface {
	Decode([]byte, interface{}) error
}

Decoder decode Bytes to Type

type Encoder

type Encoder interface {
	Encode(interface{}) ([]byte, error)
}

Encoder encode Type to Bytes

type Formatter

type Formatter interface {
	Format(dest interface{}, src interface{}) error
}

Formatter format v to v

type JSON

type JSON struct{}

JSON implements Codec and Formatter interface

func NewJSONCodec

func NewJSONCodec() JSON

NewJSONCodec jsoncodec

func (JSON) Decode

func (JSON) Decode(b []byte, v interface{}) error

Decode implate Decoder interface

func (JSON) Encode

func (JSON) Encode(v interface{}) ([]byte, error)

Encode implate Encoder interface

func (JSON) Format

func (json JSON) Format(dest, src interface{}) error

Format implate Formater interface

func (JSON) String

func (JSON) String() string

type StringList

type StringList []string

StringList stringList

func (StringList) Bytes

func (sList StringList) Bytes() ([]byte, error)

Bytes bytes

func (StringList) MarshalJSON

func (sList StringList) MarshalJSON() ([]byte, error)

MarshalJSON implement json.Marshaler interface

type YAML

type YAML struct{}

YAML implements Codec and Formatter interface

func NewYAMLCodec

func NewYAMLCodec() YAML

NewYAMLCodec yamlcodec

func (YAML) Decode

func (YAML) Decode(b []byte, v interface{}) error

Decode implate Decoder interface

func (YAML) Encode

func (YAML) Encode(v interface{}) ([]byte, error)

Encode implate Encoder interface

func (YAML) Format

func (yaml YAML) Format(dest, src interface{}) error

Format implate Formater interface

func (YAML) String

func (YAML) String() string

Jump to

Keyboard shortcuts

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