proto

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package proto 提供 Protocol Buffers 格式的编解码器实现。 支持对实现 proto.Message 接口的对象进行序列化和反序列化。

使用示例:

// 使用默认编解码器
data, err := proto.Marshal(message)
err = proto.Unmarshal(data, &message)

// 或通过 encoding 包使用
codec := encoding.Invoke("proto")
data, err := codec.Marshal(message)

Index

Constants

View Source
const Name = "proto"

Variables

View Source
var DefaultCodec = &codec{}

Functions

func Marshal

func Marshal(v any) ([]byte, error)

Marshal 使用默认编解码器将 proto.Message 编码为字节数组。 如果 v 不实现 proto.Message 接口,返回 ProtoMarshalError 错误。

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal 使用默认编解码器将字节数组解码为 proto.Message。 如果 v 不实现 proto.Message 接口,返回 ProtoUnmarshalError 错误。

Types

This section is empty.

Jump to

Keyboard shortcuts

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