connect-go: Generate Connect RPC Handlers in CI
protoc-gen-connect-go generates Connect RPC Go handlers and clients that interoperate with gRPC and gRPC-Web over plain HTTP.
Connect (connectrpc.com) is a gRPC-compatible RPC framework. Its code generator, protoc-gen-connect-go, runs as a normal protoc/buf plugin alongside protoc-gen-go.
What it does
protoc-gen-connect-go produces *.connect.go files with Connect handlers and clients for each service. Connect servers also accept gRPC and gRPC-Web requests, so you can call them with grpcurl or a standard gRPC client. It depends on the message types from protoc-gen-go, so run both.
Common usage
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest
# buf.gen.yaml (v2)
# plugins:
# - remote: buf.build/protocolbuffers/go
# out: gen
# opt: paths=source_relative
# - local: protoc-gen-connect-go
# out: gen
# opt: paths=source_relative
buf generateFlags and options
| Item | What it does |
|---|---|
| --connect-go_out=<dir> | Invoke the plugin under raw protoc |
| --connect-go_opt=paths=source_relative | Mirror the .proto directory layout |
| local: protoc-gen-connect-go | Reference the plugin from buf.gen.yaml |
| package option | Output package is driven by the proto go_package |
In CI
Run protoc-gen-connect-go together with protoc-gen-go (Connect needs the message types). Using buf generate with a local: Connect plugin and a remote: Go plugin is a common, reproducible setup. Because Connect handlers also serve gRPC, your existing grpcurl and grpc_health_probe checks keep working.
Common errors in CI
"protoc-gen-connect-go: program not found or is not executable" means the plugin was not installed or is off PATH; go install connectrpc.com/connect/cmd/protoc-gen-connect-go@<version>. A Go build error referencing missing *pb.go types means you generated Connect code without also running protoc-gen-go. Make sure the go_package option is set so the generated package path resolves.