Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect RPC import path being the Buf-tour path #736

Closed
sudowoodo200 opened this issue May 18, 2024 · 5 comments
Closed

Connect RPC import path being the Buf-tour path #736

sudowoodo200 opened this issue May 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@sudowoodo200
Copy link

Describe the bug

.connect.go file imports .pb.go file as v1 "github.com/bufbuild/buf-tour/gen/v1". Totally wrong. I believe it's because my proto directory has "v1"

To Reproduce

buf.gen.yaml

   - plugin: buf.build/protocolbuffers/go
    out: go/pkgs/bindings/proto
    opt:
      - paths=source_relative
  - plugin: buf.build/connectrpc/go
    out: go/pkgs/bindings/proto
    opt:
      - paths=source_relative

command

buf generate --path ./v1/*.proto

Results:

// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: v1/test.proto

package v1connect

import (
	connect "connectrpc.com/connect"
	context "context"
	errors "errors"
	v1 "github.com/bufbuild/buf-tour/gen/v1"
	http "net/http"
	strings "strings"
)

Additional context
Add any other context about the problem here.

@sudowoodo200 sudowoodo200 added the bug Something isn't working label May 18, 2024
@hirasawayuki
Copy link

@sudowoodo200
Could you please provide the contents of your *.proto file as well?
This will help in diagnosing the issue more accurately. The current description lacks the *.proto file details, making it unclear if the issue is due to a bug or the specific configuration of the proto file.

@sudowoodo200
Copy link
Author

Yup here you go:

syntax = "proto3";
package foo;

enum Gender {
  MALE = 0;
  FEMALE = 1;
}

message Response {
  string id = 1;
  string text = 2;
}

message Person {
  string name = 1;
  Gender gender = 2;
}

service TestService {
  rpc Hello (Person) returns (Response);
  rpc StreamHello (Person) returns (stream Response);
  rpc Echo (stream Person) returns (stream Response);
}

@hirasawayuki
Copy link

The issue seems to be caused by not specifying the go_package option.
I suggest trying to add the following to your proto file:

option go_package = "{module_name}/go/pkgs/bindings/proto/v1;foov1";

@jhump
Copy link
Member

jhump commented May 20, 2024

@sudowoodo200, this configuration looks incomplete. As @hirasawayuki points out, the proto has no Go package option. And the buf.gen.yaml snippet doesn't indicate any managed mode configuration. Did you omit that when you pasted the config?

Also, you don't actually state what you were expecting as the import path. What is the intent? Why is the generated import "totally wrong"?

@sudowoodo200
Copy link
Author

sudowoodo200 commented May 21, 2024

@jhump , @hirasawayuki -- extremely helpful, thank you! Both are bona fide omissions. Let me go try it. I simply ported over the code that I used for grpc-go and was taken aback by the buf-tour import.

Update: Solved! My bad, sorry guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants