serializer

package
v0.0.0-...-3470e27 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListSerializers

func ListSerializers() []string

ListSerializers 列出所有可用的序列化器

func Register

func Register(name string, s Serializer)

Register 注册序列化器

func SetDefault

func SetDefault(name string) error

SetDefault 设置默认序列化器

Types

type GobSerializer

type GobSerializer struct{}

GobSerializer Gob 序列化器

func (*GobSerializer) Marshal

func (s *GobSerializer) Marshal(v interface{}) ([]byte, error)

func (*GobSerializer) Name

func (s *GobSerializer) Name() string

func (*GobSerializer) Unmarshal

func (s *GobSerializer) Unmarshal(data []byte, v interface{}) error

type JSONSerializer

type JSONSerializer struct{}

JSONSerializer JSON 序列化器

func (*JSONSerializer) Marshal

func (s *JSONSerializer) Marshal(v interface{}) ([]byte, error)

func (*JSONSerializer) Name

func (s *JSONSerializer) Name() string

func (*JSONSerializer) Unmarshal

func (s *JSONSerializer) Unmarshal(data []byte, v interface{}) error

type MessagePackSerializer

type MessagePackSerializer struct{}

MessagePackSerializer MessagePack 序列化器

func (*MessagePackSerializer) Marshal

func (s *MessagePackSerializer) Marshal(v interface{}) ([]byte, error)

func (*MessagePackSerializer) Name

func (s *MessagePackSerializer) Name() string

func (*MessagePackSerializer) Unmarshal

func (s *MessagePackSerializer) Unmarshal(data []byte, v interface{}) error

type Serializer

type Serializer interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
	Name() string
}

Serializer 序列化器接口

func Get

func Get(name string) (Serializer, error)

Get 获取序列化器

func GetDefault

func GetDefault() Serializer

GetDefault 获取默认序列化器

Jump to

Keyboard shortcuts

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