protopatch icon indicating copy to clipboard operation
protopatch copied to clipboard

Fails when using with protoc-gen-connect-go

Open ghost opened this issue 1 year ago • 2 comments

Enabling debug logging shows the following error:

Parse Go:       helloworldconnect/helloworld.connect.go
Error: unknown package: helloworldconnect
Failure: plugin protoc-gen-go-patch: exit status 1

The connect go generator forces the connect rpc stub generation to be in a sub-package to avoid namespace conflicts which I imagine is why it fails.

ghost avatar Aug 30 '24 04:08 ghost

Can you provide a small reproducible example? I'll take a look.

ydnar avatar Aug 31 '24 19:08 ydnar

Sure

Create example.proto with the following contents:

syntax = "proto3";

option go_package = "example.com/example";

service ExampleService {
  rpc ExampleRPC(ExampleMessage) returns (ExampleMessage);
}

message ExampleMessage {}

Run the following:

$ PROTO_PATCH_DEBUG_LOGGING=true protoc -I . --go-patch_out=plugin=connect-go:. example.proto 

Scan proto:     example.proto
Generating:     example.proto
Go package:     example "example.com/example"

Parse Go:       example.com/example/exampleconnect/example.connect.go
Error: unknown package: exampleconnect
--go-patch_out: protoc-gen-go-patch: Plugin failed with status code 1.

Note of course you will need protoc-gen-connect-go which can be installed with:

go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest

ghost avatar Sep 02 '24 06:09 ghost