alta / protopatch

protoc-gen-go patch utility
MIT License
103 stars 18 forks source link

Fails when using with protoc-gen-connect-go #171

Open ghost opened 3 months ago

ghost commented 3 months ago

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.

ydnar commented 3 months ago

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

ghost commented 3 months ago

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