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

error when package name same with message name in rpc service #2879

Closed
soxft opened this issue Feb 13, 2023 · 0 comments
Closed

error when package name same with message name in rpc service #2879

soxft opened this issue Feb 13, 2023 · 0 comments

Comments

@soxft
Copy link

soxft commented Feb 13, 2023

Describe the bug

when package name is same with message name in example.proto, and generate code with goctl.

then it will throw 'xxx redeclared in this block'

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is

proto file looks like:

syntax = "proto3";

package video;

option go_package = "./video";

message Video {
  int64 id = 1;
  // User author = 2;
  int64 user_id = 2;
  string play_url = 3;
  string cover_url = 4;
  string title = 8;
}

message feedReq {
  int64 latest_time = 1;
}
message feedResp {
  repeated Video video_list = 3;
  optional int64 next_time = 4;
}


service video {
  rpc feed(feedReq) returns (feedResp);
}

And in /path/to/video/videoclient/video.go

type (
	Video              = video.Video

	Video interface {
		Feed(ctx context.Context, in *FeedReq, opts ...grpc.CallOption) (*FeedResp, error)
	}
)
  1. The error is

Video interface and video message conflict

Environments (please complete the following information):

  • darwin/arm64
  • go-zero version latest
  • goctl version 1.4.3 darwin/arm64

More description

I think when message name is same as package name,goctl should give a suffix to message type name

kesonan added a commit to kesonan/go-zero that referenced this issue Mar 3, 2023
@kevwan kevwan closed this as completed in 4bc1b78 Mar 3, 2023
kevwan pushed a commit that referenced this issue Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant