2. buf.build
2.1. Install buf CLI
From sources:
$ go install github.com/bufbuild/buf/cmd/buf@latest
$ buf --version
1.70.0
2.2. Usage
In your source directory:
$ buf config init
Would create a file buf.yaml, like:
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
version: v2
lint:
use:
- STANDARD
breaking:
use:
- FILE
Modify it to add a dependency (necessary for Connect):
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
version: v2
+deps:
+ - buf.build/bufbuild/protovalidate
lint:
use:
- STANDARD
Then a buf.gen.yaml is needed. See https://github.com/lasyard/coding-go/blob/main/connect/buf.gen.yaml for an example. Then the codes can be generated by:
$ buf dep update
$ buf lint
$ buf generate