Protobuf Tools
Buf is a tool for Protobuf files:

Prerequisites

1
# buf: proto tool https://buf.build/docs/tour-1
2
brew tap bufbuild/buf
3
brew install buf
4
# or use `go get` to install Buf
5
GO111MODULE=on go get github.com/bufbuild/buf/cmd/buf
Copied!

Developer Workflow

Info

1
# To list all files Buf is configured to use:
2
buf ls-files
3
# To see your currently configured lint or breaking checkers:
4
buf check ls-lint-checkers
5
buf check ls-breaking-checkers
6
# To see all available lint checkers independent of configuration/defaults:
7
buf check ls-lint-checkers --all
Copied!

Build

1
# check
2
buf image build -o /dev/null
3
buf image build -o image.bin
Copied!

Lint

1
buf check lint
2
# We can also output errors in a format you can then copy into your buf.yaml file
3
buf check lint --error-format=config-ignore-yaml
4
# Run breaking change detection
5
# for dev local
6
buf check breaking --against-input image.bin
7
buf check breaking --against-input '.git#branch=master'
8
# for CI
9
export HTTPS_GIT=https://github.com/xmlking/yeti.git
10
buf check breaking --against-input "$(HTTPS_GIT)#branch=master"
Copied!

Format

1
make proto_format
Copied!

Generate

1
make proto
Copied!

Tools

grpcurl

1
# To use Buf-produced FileDescriptorSets with grpcurl on the fly:
2
grpcurl -protoset <(buf image build -o -) ...
Copied!

ghz

1
# To use Buf-produced FileDescriptorSets with ghz on the fly:
2
ghz --protoset <(buf image build -o -) ...
Copied!

Reference

    1.
    2.
    Buf docs
    3.
Last modified 9mo ago