codec

package
v0.0.0-...-16c191e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

README

实现各种编码方式的封装,提供统一的编解码方式

todo:

  • binary
  • gob
  • json
  • pb
  • jce

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Marshal(v any) ([]byte, error)
	MarshalTo(v any, w io.Writer) error
	Unmarshal(data []byte, v any) error
	UnmarshalFrom(r io.Reader, v any) error
	String() string
}

codec 接口 TODO: 这里考虑重新设计接口, 内部加缓存?

func Coder

func Coder(codeType Type) Codec

根据类型获取编码器

type Type

type Type string
const (
	CodeTypeGob    Type = "code/gob"
	CodeTypeJce    Type = "code/jce"
	CodeTypeJson   Type = "code/json"
	CodeTypePb     Type = "code/pb"
	CodeTypeBinary Type = "code/binary"
)

func (Type) String

func (t Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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