### Clone example repository Source: https://buf.build/docs/breaking/quickstart?q= Clone the Buf examples repository and navigate to the quickstart's starting directory. ```bash $ git clone git@github.com:bufbuild/buf-examples.git $ cd buf-examples/cli/breaking-change-detection/start ``` -------------------------------- ### Clone and Navigate to Example Directory Source: https://buf.build/docs/bsr/checks/plugins/tutorial Clone the Buf examples repository and navigate to the quickstart directory. This sets up the initial project structure. ```bash $ git clone git@github.com:bufbuild/buf-examples.git $ cd buf-examples/bsr/buf-check-plugin/start ``` -------------------------------- ### Install Go SDK using go get Source: https://buf.build/docs/bsr/generated-sdks/go?q= Use `go get` to download and install a Go SDK from the BSR. The BSR acts as a Go module proxy, serving generated SDKs on demand. ```bash $ go get buf.build/gen/go/connectrpc/eliza/connectrpc/go go: downloading buf.build/gen/go/connectrpc/eliza/connectrpc/go v1.11.0-20230913231627-233fca715f49.1 go: added buf.build/gen/go/connectrpc/eliza/connectrpc/go v1.11.0-20230913231627-233fca715f49.1 ``` -------------------------------- ### Install Generated Go SDKs Source: https://buf.build/docs/bsr/quickstart?q= Navigate to the client directory and install the base Protobuf types and the generated invoice SDK using `go get`. The first `go get` for a new module may take a few seconds as the BSR generates SDKs on demand. ```bash cd ../client go get buf.build/gen/go/-quickstart/invoice/protocolbuffers/go # Base Protobuf types go get buf.build/gen/go/-quickstart/invoice/connectrpc/gosimple # The generated invoice SDK ``` -------------------------------- ### Install Generated Go SDK Source: https://buf.build/docs/bsr/generated-sdks/artifactory?q= Use the `go get` command to install a generated SDK from the BSR via Artifactory. ```bash $ go get buf.example.com/gen/go/connectrpc/eliza/connectrpc/go ``` -------------------------------- ### Install Go SDK for a specific label Source: https://buf.build/docs/bsr/generated-sdks/go Installs a Go SDK from the BSR using `go get` with a specific label reference. ```bash $ go get buf.build/gen/go/connectrpc/eliza/connectrpc/go@LABEL ``` -------------------------------- ### Install Go SDK for an explicit version string Source: https://buf.build/docs/bsr/generated-sdks/go Installs a Go SDK from the BSR using `go get` with an explicit version string, including plugin version, timestamp, and commit ID. ```bash $ go get buf.build/gen/go/connectrpc/eliza/connectrpc/go@v1.11.0-20230727062025-d8fbf2620c60.1 ``` -------------------------------- ### Example package.json Dependency Source: https://buf.build/docs/bsr/generated-sdks/quickstart An example of how a BSR-generated SDK appears as a dependency in a project's package.json file after installation. ```json "dependencies": { "@buf/connectrpc_eliza.bufbuild_es": "^2.2.2-20230822171018-8b8b971d6fde" } ``` -------------------------------- ### Install Custom Plugin Generated SDK Source: https://buf.build/docs/bsr/remote-plugins/custom-plugins Install an SDK generated from the custom plugin. This example shows installing a CommonJS version. ```bash $ npm install @buf/acme_petapis.custom-plugins_bufbuild-es@latest ``` -------------------------------- ### Install Buf CLI from source on Windows Source: https://buf.build/docs/cli/installation Installs the Buf CLI from source using 'go install' on Windows. Ensure GOBIN is set or defaults to %GOPATH%\bin. ```go # Substitute GOBIN for your bin directory. # Leave unset to default to %GOPATH%\bin. GOBIN=C:\\dev\\go\\bin go install github.com/bufbuild/buf/cmd/buf@v1.70.0 ``` -------------------------------- ### Example Go SDK version string Source: https://buf.build/docs/bsr/generated-sdks/go A concrete example of a Go SDK version string, illustrating the format and components. ```plaintext v1.11.0-20230727062025-d8fbf2620c60.1 ``` -------------------------------- ### Run setup only Source: https://buf.build/docs/bsr/ci-cd/github-actions?q= Installs the Buf CLI without running checks, allowing direct use of `buf` in subsequent steps. ```yaml - uses: bufbuild/buf-action@v1 with: setup_only: true - run: buf build --error-format github-actions ``` -------------------------------- ### Install Go SDK for latest commit Source: https://buf.build/docs/bsr/generated-sdks/go Installs the latest commit of a Go SDK from the BSR using `go get` with the `@latest` reference. ```bash $ go get buf.build/gen/go/connectrpc/eliza/connectrpc/go@latest ``` -------------------------------- ### Fetch Go SDK using go get Source: https://buf.build/docs/bsr/generated-sdks/go Use `go get` to download and install a generated Go SDK from the BSR. This command fetches the latest commit on the default label. ```bash $ go get buf.build/gen/go/connectrpc/eliza/connectrpc/go ``` -------------------------------- ### Start the Generated Go Server Source: https://buf.build/docs/bsr/quickstart Execute the main Go application to start the server, which will be listening for requests on localhost:8080. ```bash $ go run cmd/main.go ``` -------------------------------- ### Example Go import path with Protobuf package Source: https://buf.build/docs/bsr/generated-sdks/go An example demonstrating the import path format when including a Protobuf package. ```plaintext buf.build/gen/go/connectrpc/eliza/connectrpc/go/connectrpc/eliza/v1 ``` -------------------------------- ### Full Runnable Example: Go SDK for Reflection API Source: https://buf.build/docs/bsr/apis/api-access?q= This is a complete, runnable Go example demonstrating how to fetch a FileDescriptorSet using the BSR Reflection API. It includes necessary imports and error handling. The example is located at bsr/api-access/example/example.go. ```go package example import ( "context" "net/http" reflectv1beta1connect "buf.build/gen/go/bufbuild/reflect/connectrpc/gosimple/buf/reflect/v1beta1/reflectv1beta1connect" reflectv1beta1 "buf.build/gen/go/bufbuild/reflect/protocolbuffers/go/buf/reflect/v1beta1" ) func Example() (*reflectv1beta1.GetFileDescriptorSetResponse, error) { client := reflectv1beta1connect.NewFileDescriptorSetServiceClient( http.DefaultClient, "https://buf.build", ) request := &reflectv1beta1.GetFileDescriptorSetRequest{ Module: "buf.build/connectrpc/eliza", } // If you're using a private BSR, set your Authorization header to a // BUF_TOKEN value. // // request.Header().Set("Authorization", "Bearer ") response, err := client.GetFileDescriptorSet(context.Background(), request) if err != nil { return nil, err } return response, nil } ``` -------------------------------- ### Install Go SDK for a specific commit Source: https://buf.build/docs/bsr/generated-sdks/go Installs a specific version of a Go SDK from the BSR using `go get` with a commit ID. ```bash $ go get buf.build/gen/go/connectrpc/eliza/connectrpc/go@COMMIT_ID ``` -------------------------------- ### Install Go Connect Client Source: https://buf.build/docs/bsr/admin/instance/webhooks Installs the necessary Go package for the Connect RPC client for Buf Registry webhooks. ```bash $ go get buf.build/gen/go/bufbuild/buf/connectrpc/go ``` -------------------------------- ### Install Buf CLI from source on macOS/Linux Source: https://buf.build/docs/cli/installation Installs the Buf CLI from source using 'go install' on macOS or Linux. Ensure GOBIN is set or defaults to $GOPATH/bin. ```go # Substitute GOBIN for your bin directory. # Leave unset to default to $GOPATH/bin. GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/buf@v1.70.0 ``` -------------------------------- ### Example Go import path with plugin subpackage Source: https://buf.build/docs/bsr/generated-sdks/go An example showing the import path including a plugin subpackage for Connect RPC services. ```plaintext buf.build/gen/go/connectrpc/eliza/connectrpc/go/connectrpc/eliza/v1/elizav1connect ``` -------------------------------- ### Example Proto3 Syntax Source: https://buf.build/docs/reference/descriptors This is an example of a proto3 syntax definition that will be compiled into a FileDescriptorProto. ```protobuf syntax = "proto3"; package foo.bar; enum Foo { FOO_UNSPECIFIED = 0; FOO_BAR = 1; FOO_BAZ = 2; } message Fizz { string name = 1; } message Buzz { uint64 id = 1; repeated string tags = 2; Foo foo = 3; } ``` -------------------------------- ### Example Proto3 Syntax Source: https://buf.build/docs/reference/descriptors?q= This is an example of a proto3 syntax definition that will be used to illustrate the structure of a FileDescriptorProto. ```protobuf syntax = "proto3"; package foo.bar; enum Foo { FOO_UNSPECIFIED = 0; FOO_BAR = 1; FOO_BAZ = 2; } message Fizz { string name = 1; } message Buzz { uint64 id = 1; repeated string tags = 2; Foo foo = 3; } ``` -------------------------------- ### Install a Buf-generated npm SDK Source: https://buf.build/docs/bsr/generated-sdks/npm?q= Install a specific SDK generated by the Buf Registry. The first install of a version may take longer as it's generated on demand. ```bash $ npm install @buf/connectrpc_eliza.bufbuild_es ``` -------------------------------- ### Install Plugin and Tidy Dependencies Source: https://buf.build/docs/bsr/checks/plugins/tutorial?q= Run go mod tidy to update dependencies and go install to build and install the plugin binary. ```bash $ go mod tidy $ go install ./cmd/rpc-suffix ``` -------------------------------- ### Examples of Go import paths Source: https://buf.build/docs/bsr/generated-sdks/go Provides concrete examples of Go import paths for public, Pro, and Enterprise BSR instances. ```plaintext buf.build/gen/go/connectrpc/eliza/connectrpc/go # public BSR your-bsr-instance.buf.dev/gen/go/connectrpc/eliza/connectrpc/go # Pro plan your-bsr-instance.example.com/gen/go/connectrpc/eliza/connectrpc/go # Enterprise plan ``` -------------------------------- ### Install protoc-gen-go and add to PATH Source: https://buf.build/docs/generate/tutorial Installs the protoc-gen-go plugin and ensures it is accessible in your system's PATH for local plugin execution. ```bash $ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.11 $ export PATH="$PATH:$(go env GOPATH)/bin" ``` -------------------------------- ### Example Python SDK Version Source: https://buf.build/docs/bsr/generated-sdks/python?q= An example of a generated Python SDK version string, illustrating the version format. ```plaintext 25.0.0.3.20231106214313+d8fbf2620c60 ``` -------------------------------- ### Install Go Dependencies for Webhooks Source: https://buf.build/docs/bsr/admin/instance/webhooks Installs the necessary Go packages for handling Buf webhooks using Connect RPC. ```bash go get buf.build/gen/go/bufbuild/buf/protocolbuffers/go go get buf.build/gen/go/bufbuild/buf/connectrpc/go ``` -------------------------------- ### Install Go Dependencies for Webhooks Source: https://buf.build/docs/bsr/admin/instance/webhooks?q= Install the necessary generated Go packages for handling Buf webhooks using Connect RPC. ```bash $ go get buf.build/gen/go/bufbuild/buf/protocolbuffers/go $ go get buf.build/gen/go/bufbuild/buf/connectrpc/go ``` -------------------------------- ### Install Plugin and Tidy Dependencies Source: https://buf.build/docs/bsr/checks/plugins/tutorial Install the plugin binary to make it available to the Buf CLI and tidy Go module dependencies. ```bash $ go mod tidy $ go install ./cmd/rpc-suffix ``` -------------------------------- ### Complete BSR Helm Chart Configuration Example Source: https://buf.build/docs/bsr/admin/on-prem/installation A comprehensive example of a bsr.yaml file demonstrating S3 storage, OIDC authentication, and TLS certificate configuration. ```yaml host: example.com license: key: "buflicense-..." storage: use: s3 s3: bucketName: "my-bucket-name" region: "us-east-1" postgres: host: "postgres.example.com" port: 5432 database: postgres user: postgres # The Redis address is set in the "bufd-redis" secret's "address" field # (e.g. "redis.example.com:6379"); see "Configure Redis" above. redis: # Set to true if your Redis requires authentication. The auth token # is read from the "auth" field in the "bufd-redis" secret. auth: true tls: # "false" disables TLS, "local" uses the "ca" field in the # "bufd-redis" secret, "system" uses the system trust store. use: "system" auth: method: oidc oidc: # Only one of `issuerURL` or `discoveryURL` can be set. issuerURL: "https://idp.example.com" clientID: "bsr" autoProvisionedAdminEmails: - "user@example.com" bufd: ingress: enabled: true hosts: - host: example.com paths: - path: / portName: http tls: - secretName: bsr-tls-cert hosts: - example.com # Mount additional trusted certificates (chart v1.15.2 and newer). # Use bufd.deployment.extraVolumes / clientTLS on older charts. clientTLSSecrets: tls-cert: cert.pem observability: metrics: use: prometheus runtime: true prometheus: podLabels: # Required if enabling network policies. app: prometheus port: 9090 path: /metrics ``` -------------------------------- ### Running buf lint and an example error Source: https://buf.build/docs/lint Demonstrates running the `buf lint` command and an example output indicating a package naming convention error. ```bash $ buf lint weather/weather.proto:3:1:Package name "weather" should be suffixed with a correctly formed version, such as "weather.v1". ``` -------------------------------- ### Install Python SDK with pip Source: https://buf.build/docs/bsr/generated-sdks/python?q= Install a generated Python SDK using pip. Ensure the BSR's PEP 503 repository is configured. ```bash $ pip install connectrpc-eliza-protocolbuffers-python ``` -------------------------------- ### Initialize Go Module and Create Plugin Entry Point Source: https://buf.build/docs/bsr/checks/plugins/tutorial?q= Initialize the Go module and create the main.go file for the plugin. ```bash $ go mod init plugin/quickstart $ mkdir -p cmd/rpc-suffix $ touch cmd/rpc-suffix/main.go ``` -------------------------------- ### Example pyproject.toml Dependencies Source: https://buf.build/docs/bsr/generated-sdks/python?q= This is an example of how the output from the previous command will appear in your `pyproject.toml` file. It uses compatible release version constraints (`~=`) and specifies the source as 'buf'. ```toml acme-petapis-grpc-python = {version = "~1.72.1.1.20220907172654+7abdb7802c8f", source = "buf"} acme-petapis-protocolbuffers-python = {version = "~31.1.0.1.20220907172654+7abdb7802c8f", source = "buf"} acme-petapis-protocolbuffers-pyi = {version = "~31.1.0.1.20220907172654+7abdb7802c8f", source = "buf"} acme-paymentapis-grpc-python = {version = "~1.72.1.1.20220907172603+9a877cf260e1", source = "buf"} ggoogleapis-googleapis-grpc-python = {version = "~1.72.1.1.20220906171522+62f35d8aed11", source = "buf"} acme-paymentapis-protocolbuffers-python = {version = "~31.1.0.1.20220907172603+9a877cf260e1", source = "buf"} ggoogleapis-googleapis-protocolbuffers-python = {version = "~31.1.0.1.20220906171522+62f35d8aed11", source = "buf"} acme-paymentapis-protocolbuffers-pyi = {version = "~31.1.0.1.20220907172603+9a877cf260e1", source = "buf"} googleapis-googleapis-protocolbuffers-pyi = {version = "~31.1.0.1.20220906171522+62f35d8aed11", source = "buf"} ``` -------------------------------- ### Start the Generated Go Server Source: https://buf.build/docs/bsr/quickstart?q= Run the main application file to start the server. This command assumes the server's entry point is `cmd/main.go` and it will begin listening on `localhost:8080`. ```bash $ go run cmd/main.go ... Listening on localhost:8080 ``` -------------------------------- ### Initial Project Structure Source: https://buf.build/docs/bsr/checks/plugins/tutorial The starting workspace contains a buf.yaml and proto files. This illustrates the basic project layout. ```text . ├── buf.yaml └── proto └── pet └── v1 └── pet.proto ``` -------------------------------- ### Get SDK version for module and plugin Source: https://buf.build/docs/reference/cli/buf/registry/sdk/version Use this command to get the version of a module and plugin, for example, when using the Go module proxy. ```bash $ buf registry sdk version --module=buf.build/connectrpc/eliza --plugin=buf.build/protocolbuffers/go v1.33.0-20230913231627-233fca715f49.1 ``` -------------------------------- ### Protoc Plugin Options Example Source: https://buf.build/docs/configuration/v2/buf-gen-yaml?q= Demonstrates how to specify plugin options using the 'opt' key in buf.gen.yaml. This is equivalent to using the --_opt flag in protoc. ```yaml plugins: - local: protoc-gen-foo out: bar opt: - x=y - a=b ``` -------------------------------- ### npm Dependencies in package.json Source: https://buf.build/docs/bsr/generated-sdks/quickstart?q= Example of how an installed BSR-generated SDK is added to the dependencies in a project's package.json file. ```json "dependencies": { "@buf/connectrpc_eliza.bufbuild_es": "^2.2.2-20230822171018-8b8b971d6fde" } ``` -------------------------------- ### Starter main.go for RPC Suffix Plugin Source: https://buf.build/docs/bsr/checks/plugins/tutorial?q= This Go code initializes the plugin with a rule specification and a placeholder handler. ```go // Copyright 2020-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package main import ( "context" "buf.build/go/bufplugin/check" "buf.build/go/bufplugin/check/checkutil" "google.golang.org/protobuf/reflect/protoreflect" ) var ( rpcSuffixRuleSpec = &check.RuleSpec{ ID: "RPC_SUFFIX", Default: true, Purpose: "Checks that RPC names don't end with an illegal suffix.", Type: check.RuleTypeLint, Handler: checkutil.NewMethodRuleHandler(checkRPCSuffix, checkutil.WithoutImports()), } ) func main() { check.Main(&check.Spec{ Rules: []*check.RuleSpec{ rpcSuffixRuleSpec, }, }) } func checkRPCSuffix( _ context.Context, responseWriter check.ResponseWriter, _ check.Request, methodDescriptor protoreflect.MethodDescriptor, ) error { responseWriter.AddAnnotation( check.WithMessage("hello world"), ) return nil } ``` -------------------------------- ### Verify Buf CLI installation Source: https://buf.build/docs/cli/installation Checks the installed Buf CLI version to confirm a successful installation. ```bash $ buf --version ``` -------------------------------- ### Module Documentation README Example Source: https://buf.build/docs/bsr/documentation To add module-level documentation, place a README.md, README.markdown, or buf.md file at the root of the module. buf.md takes precedence if multiple files exist. ```protobuf syntax = "proto3"; package main.options.v1; extend google.protobuf.EnumValueOptions { string country_code_abbrv = 2000; } enum CountryCode { COUNTRY_CODE_UNSPECIFIED = 0; COUNTRY_CODE_INDIA = 1 [(country_code_abbrv) = "IND"]; COUNTRY_CODE_UNITED_KINGDOM = 2 [(country_code_abbrv) = "GBR"]; COUNTRY_CODE_UNITED_STATE_OF_AMERICA = 3 [(country_code_abbrv) = "USA"]; } ``` -------------------------------- ### Install Generated NPM SDK Source: https://buf.build/docs/bsr/generated-sdks/artifactory?q= Use the `npm install` command to install a generated SDK from the BSR via Artifactory. ```bash $ npm install @buf/connectrpc_eliza.connectrpc_es ``` -------------------------------- ### Install Generated NPM SDK Source: https://buf.build/docs/bsr/generated-sdks/artifactory Use the `npm install` command to install a generated SDK from the BSR through Artifactory. Ensure the scope and package name are correct. ```bash $ npm install @buf/connectrpc_eliza.connectrpc_es ``` -------------------------------- ### Create Server Files Source: https://buf.build/docs/cli/quickstart Creates the server directory and the main Go file for the server implementation. ```bash mkdir server touch server/main.go ``` -------------------------------- ### Install Graphviz Source: https://buf.build/docs/reference/cli/buf/dep/graph Command to install Graphviz via Homebrew. ```bash brew install graphviz ``` -------------------------------- ### Example Protobuf File with Options Source: https://buf.build/docs/reference/descriptors?q= This example demonstrates how to declare file, message, and field options within a .proto file. It shows the syntax for applying options like go_package, java_package, deprecated, packed, and debug_redact. ```protobuf syntax = "proto3"; package foo.bar; // These next two lines are file options option go_package = "github.com/foo/bar"; option java_package = "com.foo.bar"; message Foo { // This is a message option option deprecated = true; string name = 1; // This field has an option (packed) repeated int64 class_ids = 2 [packed = true]; // As does this one (debug_redact) string ssn = 3 [debug_redact = true]; } ``` -------------------------------- ### Scaffold Go Module and Plugin Entry Point Source: https://buf.build/docs/bsr/checks/plugins/tutorial Initialize the Go module and create the plugin's main Go file. This sets up the basic Go project for the plugin. ```bash $ go mod init plugin/quickstart $ mkdir -p cmd/rpc-suffix $ touch cmd/rpc-suffix/main.go ``` -------------------------------- ### Example Protobuf file Source: https://buf.build/docs/lint A simple Protobuf file defining a package. ```protobuf syntax = "proto3"; package weather; ``` -------------------------------- ### Module Input Example Source: https://buf.build/docs/configuration/v2/buf-gen-yaml Example of specifying a remote BSR module as an input for code generation. ```yaml module: buf.build/acme/weather:main ``` -------------------------------- ### Local workspace example structure Source: https://buf.build/docs/migration-guides/migrate-v2-config-files Shows a typical local workspace layout with buf.gen.yaml, buf.yaml, proto files, and other directories. ```text workspace_root ├── buf.gen.yaml ├── buf.yaml ├── proto │ ├── foo │ │ └── foo.proto │ └── bar │ └── bar.proto └── baz └── baz.proto ``` -------------------------------- ### Show diff example Source: https://buf.build/docs/format This is an example of the unified diff output generated by `buf format -d`. ```diff diff -u proto/simple/v1/simple.proto.orig proto/simple/v1/simple.proto --- proto/simple/v1/simple.proto.orig ... +++ proto/simple/v1/simple.proto ... @@ -2,8 +2,7 @@ package simple.v1; - message Object { - string key = 1; - bytes value = 2; + string key = 1; + bytes value = 2; } ``` -------------------------------- ### Go Protobuf Plugin Initialization Source: https://buf.build/docs/reference/descriptors?q= This Go code shows how to set up a Protobuf code generation plugin using the protogen package. It initializes the plugin options and runs the generation logic within a callback function. ```Go package main import "google.golang.org/protobuf/compiler/protogen" func main() { protogen.Options{}.Run(func(plugin *protogen.Plugin) error { // ... generate code ... }) } ``` -------------------------------- ### Export module with documentation and license files Source: https://buf.build/docs/bsr/module/export Use the `--all` flag to include documentation (`buf.md`, `README.md`) and license files alongside the `.proto` files. For multi-module inputs, non-proto files are suffixed with the module name. ```bash $ buf export buf.build/grpc/grpc --all -o /path/to/directory ``` -------------------------------- ### Install Buf CLI with WinGet Source: https://buf.build/docs/cli/installation Installs the Buf CLI on Windows using the WinGet package manager. ```powershell winget install bufbuild.buf ``` -------------------------------- ### Install Buf CLI with Scoop Source: https://buf.build/docs/cli/installation Installs the Buf CLI on Windows using the Scoop package manager. ```powershell scoop install buf ``` -------------------------------- ### Verify Cargo Installation Source: https://buf.build/docs/bsr/generated-sdks/artifactory?q= Use `cargo tree` to verify that the SDK has been successfully installed and is recognized by Cargo. ```bash $ cargo tree ``` -------------------------------- ### Buf Generate Configuration Example (buf.gen.yaml) Source: https://buf.build/docs/reference/cli/buf/generate Example buf.gen.yaml file demonstrating configuration for code generation. Specifies version, clean option, and multiple plugins with their respective settings. ```yaml # buf.gen.yaml # The version of the generation template. # The valid values are v1beta1, v1 and v2. # Required. version: v2 # When clean is set to true, delete the directories, zip files, and/or jar files specified in the # "out" field for all plugins before running code generation. Defaults to false. # Optional. clean: true # The plugins to run. # Required. plugins: # Use the plugin hosted at buf.build/protocolbuffers/go at version v1.28.1. # If version is omitted, uses the latest version of the plugin. # One of "remote", "local" and "protoc_builtin" is required. - remote: buf.build/protocolbuffers/go:v1.28.1 # The relative output directory. # Required. out: gen/go # The revision of the remote plugin to use, a sequence number that Buf # increments when rebuilding or repackaging the plugin. revision: 4 # Any options to provide to the plugin. # This can be either a single string or a list of strings. # Optional. opt: paths=source_relative # Whether to generate code for imported files as well. # Optional. include_imports: false # Whether to generate code for the well-known types. # Optional. include_wkt: false # Include only these types for this plugin. # Optional. types: - "foo.v1.User" # Exclude these types for this plugin. # Optional. exclude_types: - "buf.validate.oneof" - "buf.validate.message" - "buf.validate.field" # The name of a local plugin if discoverable in "${PATH}" or its path in the file system. - local: protoc-gen-es out: gen/es include_imports: true include_wkt: true # The full invocation of a local plugin can be specified as a list. - local: ["go", "run", "path/to/plugin.go"] out: gen/plugin # The generation strategy to use. There are two options: # # 1. "directory" # # This will result in buf splitting the input files by directory, and making separate plugin # invocations in parallel. This is roughly the concurrent equivalent of: # # for dir in $(find . -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do # protoc -I . $(find "${dir}" -name '*.proto') # done # # Almost every Protobuf plugin either requires this, or works with this, # and this is the recommended and default value. # # 2. "all" # # This will result in buf making a single plugin invocation with all input files. # This is roughly the equivalent of: # # protoc -I . $(find . -name '*.proto') # # This is needed for certain plugins that expect all files to be given at once. # This is also the only strategy for remote plugins. # # If omitted, "directory" is used. Most users should not need to set this option. # Optional. strategy: directory # "protoc_builtin" specifies a plugin that comes with protoc, without the "protoc-gen-" prefix. - protoc_builtin: java out: gen/java # Path to protoc. If not specified, the protoc installation in "${PATH}" is used. # Optional. protoc_path: path/to/protoc ``` -------------------------------- ### Verify Python SDK Installation Source: https://buf.build/docs/bsr/generated-sdks/artifactory?q= Use pip show to verify that the Python SDK has been installed correctly. ```bash $ pip show connectrpc-eliza-protocolbuffers-python ``` -------------------------------- ### Go Client Implementation Source: https://buf.build/docs/bsr/quickstart?q= Replace the contents of `client/cmd/main.go` with this reference implementation. It sets up a gRPC client to connect to the invoice service and makes a `CreateInvoice` call with sample data. ```go package main import ( tagv1 "buf.build/gen/go/USERNAME-quickstart/common/protocolbuffers/go/tag/v1" "buf.build/gen/go/USERNAME-quickstart/invoice/connectrpc/gosimple/invoice/v1/invoicev1connect" invoicev1 "buf.build/gen/go/USERNAME-quickstart/invoice/protocolbuffers/go/invoice/v1" "context" "log" "net/http" ) func main() { client := invoicev1connect.NewInvoiceServiceClient( http.DefaultClient, "http://localhost:8080", ) _, err := client.CreateInvoice( context.Background(), &invoicev1.CreateInvoiceRequest{ Invoice: &invoicev1.Invoice{ InvoiceId: "invoice-one", CustomerId: "customer-one", LineItems: []*invoicev1.LineItem{ { UnitPrice: 999, Quantity: 2, }, }, }, Tags: &tagv1.Tags{ Tag: []string{ "bogo-campaign", "valued-customer", }, }, }, ) if err != nil { log.Fatalf("error creating valid invoice: %v", err) } log.Println("Valid invoice created") } ``` -------------------------------- ### Run the studio-agent command Source: https://buf.build/docs/reference/cli/buf/beta/studio-agent Executes the studio-agent command to start the server with specified flags. ```bash $ buf beta studio-agent [flags] ``` -------------------------------- ### Install Buf CLI with Homebrew Source: https://buf.build/docs/cli/installation Installs the Buf CLI and associated plugins on macOS or Linux using Homebrew. ```bash $ brew install bufbuild/buf/buf ``` -------------------------------- ### CommonJS SDK Usage Example Source: https://buf.build/docs/bsr/remote-plugins/custom-plugins Example of how to use an SDK generated by a custom plugin that outputs CommonJS modules. ```javascript "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const { proto3 } = require("@bufbuild/protobuf"); const { Money } = require("@buf/googleapis_googleapis.custom-plugins_bufbuild-es/google/type/money_pb.js"); ``` -------------------------------- ### Uninstall Buf CLI installed from tarball Source: https://buf.build/docs/cli/installation Removes the buf CLI, protoc plugins, and associated files installed from a tarball. ```bash PREFIX="/usr/local" && \ rm -rf \ "${PREFIX}/bin/buf" \ "${PREFIX}/bin/protoc-gen-buf-breaking" \ "${PREFIX}/bin/protoc-gen-buf-lint" \ "${PREFIX}/share/fish/vendor_completions.d/buf.fish" \ "${PREFIX}/share/zsh/site-functions/_buf" \ "${PREFIX}/share/man/man1/buf*" ``` -------------------------------- ### Install Buf CLI binary from GitHub Releases Source: https://buf.build/docs/cli/installation?q= Downloads and installs the Buf CLI binary to a specified directory. Ensure the directory is on your system's PATH. Includes uninstall command. ```bash # Substitute BIN for your bin directory. # Substitute VERSION for the current released version. BIN="/usr/local/bin" && \ VERSION="1.70.0" && \ curl -sSL \ "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \ -o "${BIN}/buf" && \ chmod +x "${BIN}/buf" ``` ```bash BIN="/usr/local/bin" && \ rm -f "${BIN}/buf" ``` -------------------------------- ### Uninstall Buf CLI binary installed from GitHub Releases Source: https://buf.build/docs/cli/installation Removes the buf binary previously installed from GitHub Releases. ```bash BIN="/usr/local/bin" && \ rm -f "${BIN}/buf" ``` -------------------------------- ### Install Buf CLI binary only from GitHub Releases Source: https://buf.build/docs/cli/installation Downloads and installs only the buf binary to a specified directory, typically /usr/local/bin. ```bash # Substitute BIN for your bin directory. # Substitute VERSION for the current released version. BIN="/usr/local/bin" && \ VERSION="1.70.0" && \ curl -sSL \ "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \ -o "${BIN}/buf" && \ chmod +x "${BIN}/buf" ``` -------------------------------- ### Example: Go SDK for Reflection API Source: https://buf.build/docs/bsr/apis/api-access?q= This Go code snippet shows how to use the generated SDK to call the Reflection API. It requires the protocolbuffers-go and connect-go libraries. For private BSR instances, set the Authorization header. ```go import ( reflectv1beta1 "buf.build/gen/go/bufbuild/reflect/protocolbuffers/go/buf/reflect/v1beta1" "buf.build/gen/go/bufbuild/reflect/connectrpc/go/buf/reflect/v1beta1/reflectv1beta1connect" "connectrpc.com/connect" ) client := reflectv1beta1connect.NewFileDescriptorSetServiceClient( http.DefaultClient, "https://buf.build", ) req := connect.NewRequest(&reflectv1beta1.GetFileDescriptorSetRequest{ Module: "buf.build/connectrpc/eliza", }) req.Header().Set("Authorization", "Bearer "+os.Getenv("BUF_TOKEN")) resp, err := client.GetFileDescriptorSet(ctx, req) ``` -------------------------------- ### Install Buf CLI as a project-local npm dependency Source: https://buf.build/docs/cli/installation Installs the Buf CLI as a local dependency within a Node.js project. ```bash $ npm install @bufbuild/buf ``` -------------------------------- ### Verify NPM SDK Installation Source: https://buf.build/docs/bsr/generated-sdks/artifactory Use the `npm ls` command to verify that the installed NPM SDK is present in your project. ```bash $ npm ls @buf/connectrpc_eliza.connectrpc_es ``` -------------------------------- ### Verify NuGet Installation Source: https://buf.build/docs/bsr/generated-sdks/artifactory?q= Use `dotnet list package` to verify that the SDK has been successfully installed and is recognized by the .NET environment. ```bash $ dotnet list package ```