protobuf README

The project's README from github.com/golang/protobuf. As one markdown file: README.md.

Go support for Protocol Buffers

GoDev Build Status

This module (github.com/golang/protobuf) contains Go bindings for protocol buffers.

It has been superseded by the google.golang.org/protobuf module, which contains an updated and simplified API, support for protobuf reflection, and many other improvements. We recommend that new code use the google.golang.org/protobuf module.

Versions v1.4 and later of github.com/golang/protobuf are implemented in terms of google.golang.org/protobuf. Programs which use both modules must use at least version v1.4 of this one.

See the developer guide for protocol buffers in Go for a general guide for how to get started using protobufs in Go.

See release note documentation for more information about individual releases of this project.

See documentation for the next major revision for more information about the purpose, usage, and history of this project.

Package index

Summary of the packages provided by this module:

Reporting issues

The issue tracker for this project is located here.

Please report any issues with a sufficient description of the bug or feature request. Bug reports should ideally be accompanied by a minimal reproduction of the issue. Irreproducible bugs are difficult to diagnose and fix (and likely to be closed after some period of time). Bug reports must specify the version of the Go protocol buffer module and also the version of the protocol buffer toolchain being used.

Contributing

This project is open-source and accepts contributions. See the contribution guide for more information.

Compatibility

This module and the generated code are expected to be stable over time. However, we reserve the right to make breaking changes without notice for the following reasons:

Any breaking changes outside of these will be announced 6 months in advance to [email protected].

protobuf (golang/protobuf)

Searching Database…

10.1K ·GitHub
这是做什么用的?这是 Google protocol buffers 的 Go 语言绑定:github.com/golang/protobuf 模块用于在 Go 中序列化 protobuf 消息,另外还附带一个 protoc 插件,可以从 .proto 文件生成 Go 代码。
它是我导入的库,还是我要运行的工具?两者都是。你既可以在代码里导入 Go 包(proto、jsonpb、ptypes),也可以单独运行 protoc-gen-go——它是 protoc 编译器的一个二进制插件,用来生成你的 Go 消息包。
怎么把 .proto 文件变成 Go 代码?运行 protoc 编译器并配合 protoc-gen-go 插件;它会根据你的 .proto 定义生成一个 Go protocol buffer 包。README 里链接了一份在 Go 中上手 protobuf 的开发者指南。
README 说这个模块已经被取代了——我还该用它吗?新代码不建议用:README 推荐使用 google.golang.org/protobuf,它提供了更简洁的更新版 API、protobuf 反射以及许多其他改进。这个模块会继续存在,供已经导入它的旧代码使用。
如果我在这个模块的基础上开发,它的 API 稳定吗?模块本身和生成的代码预计会保持稳定,但团队保留在修复安全问题、规范变更、修复缺陷和内部调整时不经通知就破坏兼容性的权利;其他破坏性变更会提前 6 个月公布。
我的代码库同时导入了这个模块和新的那个——有什么要注意的吗?有:同时使用这两个模块的程序必须至少使用 v1.4 版本的 github.com/golang/protobuf,因为 v1.4 及之后的版本是基于 google.golang.org/protobuf 实现的。
除了二进制序列化,它还能对我的消息做什么?proto 包还能克隆、合并和比较消息是否相等,并输出文本格式;jsonpb 则可以把 protobuf 消息序列化成 JSON。
哪些常见的 protobuf 类型有配套的辅助包?ptypes 为 timestamp、duration、empty、any、wrappers 和 struct(structpb)提供了辅助工具——这些就是标准的 google/protobuf well-known 类型。
Creator
golang
Size
8.2 MB
Stars
10.1K
Age
11y
Commits · 90 Days