encoding

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAPointer .
	ErrNotAPointer = errors.New("v argument must be a pointer")
)

Functions

func GzipDecode

func GzipDecode(in []byte) ([]byte, error)

GzipDecode 解码

func GzipEncode

func GzipEncode(in []byte) ([]byte, error)

GzipEncode 编码

func Marshal

func Marshal(e Encoding, v interface{}) (data []byte, err error)

Marshal encode data

func Unmarshal

func Unmarshal(e Encoding, data []byte, v interface{}) (err error)

Unmarshal decode data

Types

type Encoding

type Encoding interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

Encoding 编码接口定义

type GobEncoding

type GobEncoding struct{}

GobEncoding gob encode

func (GobEncoding) Marshal

func (g GobEncoding) Marshal(v interface{}) ([]byte, error)

Marshal gob encode

func (GobEncoding) Unmarshal

func (g GobEncoding) Unmarshal(data []byte, value interface{}) error

Unmarshal gob encode

type JSONEncoding

type JSONEncoding struct{}

JSONEncoding json格式

func (JSONEncoding) Marshal

func (j JSONEncoding) Marshal(v interface{}) ([]byte, error)

Marshal json encode

func (JSONEncoding) Unmarshal

func (j JSONEncoding) Unmarshal(data []byte, value interface{}) error

Unmarshal json decode

type JSONGzipEncoding

type JSONGzipEncoding struct{}

JSONGzipEncoding json and gzip

func (JSONGzipEncoding) Marshal

func (jz JSONGzipEncoding) Marshal(v interface{}) ([]byte, error)

Marshal json encode and gzip

func (JSONGzipEncoding) Unmarshal

func (jz JSONGzipEncoding) Unmarshal(data []byte, value interface{}) error

Unmarshal json encode and gzip

type JSONSnappyEncoding

type JSONSnappyEncoding struct{}

JSONSnappyEncoding json格式和snappy压缩

func (JSONSnappyEncoding) Marshal

func (s JSONSnappyEncoding) Marshal(v interface{}) (data []byte, err error)

Marshal 序列化

func (JSONSnappyEncoding) Unmarshal

func (s JSONSnappyEncoding) Unmarshal(data []byte, value interface{}) error

Unmarshal 反序列化

type MsgPackEncoding

type MsgPackEncoding struct{}

MsgPackEncoding msgpack 格式

func (MsgPackEncoding) Marshal

func (mp MsgPackEncoding) Marshal(v interface{}) ([]byte, error)

Marshal msgpack encode

func (MsgPackEncoding) Unmarshal

func (mp MsgPackEncoding) Unmarshal(data []byte, value interface{}) error

Unmarshal msgpack decode

Jump to

Keyboard shortcuts

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