Linux command
buff 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Lint Protocol Buffer files
buf lint [path/to/protos]
Build and verify Protobuf files
buf build [path/to/protos]
Check for breaking changes
buf breaking --against [.git#branch=main]
Generate code from Protobuf
buf generate
Format Protobuf files
buf format -w [path/to/protos]
Push module to BSR
buf push
Add a dependency
buf dep add [buf.build/googleapis/googleapis]
说明
buf is a tool for working with Protocol Buffers, providing linting, breaking change detection, code generation, and a dependency management ecosystem. It addresses common pain points with protoc and large Protobuf codebases. The linting engine enforces best practices and style consistency across Protobuf definitions. Breaking change detection compares against git branches or published versions, preventing accidental API incompatibilities. Code generation is configured via buf.gen.yaml, replacing complex protoc command lines. The Buf Schema Registry (BSR) enables sharing and versioning Protobuf modules as dependencies, similar to package managers for other languages.
参数
- lint
- Run linting rules on Protobuf files.
- build
- Build Protobuf files and verify they compile.
- breaking
- Check for breaking API changes.
- generate
- Generate code using configured plugins.
- format
- Format Protobuf files.
- push
- Push module to Buf Schema Registry (BSR).
- dep
- Manage dependencies (add, update).
- convert
- Convert a message between binary, text, or JSON.
- curl
- Invoke an RPC endpoint, similar to cURL.
- export
- Export proto files from one location to another.
- config
- Work with buf configuration files.
- registry
- Manage assets on the Buf Schema Registry.
- --against _reference_
- Reference to compare against for breaking changes.
- -w, --write
- Write formatted output back to files.
- --config _path_
- Path to buf.yaml configuration.
- --error-format _format_
- Error output format: text, json, msvs, github-actions.
FAQ
What is the buff command used for?
buf is a tool for working with Protocol Buffers, providing linting, breaking change detection, code generation, and a dependency management ecosystem. It addresses common pain points with protoc and large Protobuf codebases. The linting engine enforces best practices and style consistency across Protobuf definitions. Breaking change detection compares against git branches or published versions, preventing accidental API incompatibilities. Code generation is configured via buf.gen.yaml, replacing complex protoc command lines. The Buf Schema Registry (BSR) enables sharing and versioning Protobuf modules as dependencies, similar to package managers for other languages.
How do I run a basic buff example?
Run `buf lint [path/to/protos]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does lint do in buff?
Run linting rules on Protobuf files.