codec

package
v0.51.11 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 0 Imported by: 6

README

benchmark 结果

> go test -bench .

goos: windows
goarch: amd64
pkg: github.com/zerogo-hub/zero-helper/codec
cpu: 12th Gen Intel(R) Core(TM) i7-12700F

BenchmarkMarshal_LibJSON-20              9258480               124.9 ns/op
BenchmarkMarshal_ZeroJSON-20             9724638               126.7 ns/op
BenchmarkMarshal_MsgPack-20              7323261               164.5 ns/op
BenchmarkMarshal_Protobuf-20            17642466                69.60 ns/op

BenchmarkUnmarshal_LibJSON-20            2282698               512.2 ns/op
BenchmarkUnmarshal_ZeroJSON-20          10912116               108.9 ns/op
BenchmarkUnmarshal_Msgpack-20            6285486               190.0 ns/op
BenchmarkUnmarshal_Protobuf-20          24339882                49.18 ns/op
PASS
ok      github.com/zerogo-hub/zero-helper/codec 11.332s

Documentation

Overview

Package codec 消息的编码与解码,支持 json、protobuf,默认 json 格式

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	// Marshal 将数据转为 []byte
	Marshal(in interface{}) ([]byte, error)

	// Unmarshal 将 []byte 转为数据
	Unmarshal(in []byte, out interface{}) error

	// Name 名称
	Name() string

	// MimeType 媒体类型
	MimeType() string
}

Codec 编码与解码器

Directories

Path Synopsis
Package protobuf 谷歌官方实现
Package protobuf 谷歌官方实现

Jump to

Keyboard shortcuts

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