gob

package
v0.0.0-...-ed2f012 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 6 Imported by: 0

README

golang�����������л�ʱ����ʹ��gob��Ҳ����ʹ��json��

����֮�£�json�Ƚ����ͨ��һЩ����gob�������õ���һЩ��json��һ���Ƚϴ��������ǣ�mapֻ��ʹ��string key����gob����ʹ��int��Ϊkey��

һ����Ϊ�ձ��Ľ������£�

1 ������������ʱ�����糤��Ϊ10��slice��map��json���ٶ�ԶԶ����gob������������100����ʱ�������ٶ��൱������������������ʱ��gob�����ƾͱȽ������ˡ�

2 ��gob��Encode��decode������Ϊinterface{}��gob�ڸ���������������Ч�ʶ�����json����json����Ϊinterface{}��Ӱ�첻����

3��ʹ��gobʱ��Encode��Decode��ҪNewEncoder��NewDecoder����ҲӰ����gob����ʱ��Ч�ʣ�������stream��ʽ�£�ֻ��ҪNewEncoder,NewDecoderһ�Σ�gob��Ч�ʾ����ֳ����ˡ�

���Խ�����
-ni ����δʹ��interface{}������decodeʱ�Ľ���


golang�����������л�ʱ����ʹ��gob��Ҳ����ʹ��json�� ����֮�£�json�Ƚ����ͨ��һЩ����gob�������õ���һЩ��json��һ���Ƚϴ��������ǣ�mapֻ��ʹ��string key����gob����ʹ��int��Ϊkey�� һ����Ϊ�ձ��Ľ������£� 1 ������������ʱ�����糤��Ϊ10��slice��map��json���ٶ�ԶԶ����gob������������100����ʱ�������ٶ��൱������������������ʱ��gob�����ƾͱȽ������ˡ� 2 ��gob��Encode��decode������Ϊinterface{}��gob�ڸ���������������Ч�ʶ�����json����json����Ϊinterface{}��Ӱ�첻���� 3��ʹ��gobʱ��Encode��Decode��ҪNewEncoder��NewDecoder����ҲӰ����gob����ʱ��Ч�ʣ�������stream��ʽ�£�ֻ��ҪNewEncoder,NewDecoderһ�Σ�gob��Ч�ʾ����ֳ����ˡ� ���Խ����� -ni ����δʹ��interface{}������decodeʱ�Ľ��� === RUN TestBench Gob Encode []int(2000) : Total used: 1.2708419s , Per operation: 127084 ns/ops 10000 Gob Encode-ni []int(2000) : Total used: 1.1107361s , Per operation: 111073 ns/ops

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Errortype = errors.New("type not register")
)

Functions

func ClearData

func ClearData(size uintptr, ptr unsafe.Pointer)

func DeleteType

func DeleteType(name string)

func GetMsgAllType

func GetMsgAllType() []string

func GetMsgType

func GetMsgType(name string) (reflect.Type, error)

func RegisterType

func RegisterType(typ reflect.Type)

Types

type GobConnection

type GobConnection interface {
	Read() (msg message, err error)
	Write(msg interface{}) (err error)
	Close() error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
}

func NewGobConnection

func NewGobConnection(conn net.Conn) GobConnection

Jump to

Keyboard shortcuts

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