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

gf/gen: There is a problem with the file generated by the command gf gen pb -p #3953

Open
wisonlau opened this issue Nov 20, 2024 · 2 comments · May be fixed by #3966
Open

gf/gen: There is a problem with the file generated by the command gf gen pb -p #3953

wisonlau opened this issue Nov 20, 2024 · 2 comments · May be fixed by #3966
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. help wanted

Comments

@wisonlau
Copy link

Go version

go version go1.23.1 darwin/amd64

GoFrame version

v2.7.4

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

syntax = "proto3";
package account;

option go_package = "account/v1";

service Account {
  rpc getUserByUids (GetUserByUidsRequest) returns (GetUserByUidsReply) {
  }
}

message GetUserWithdrawalInfoByUidsRequest {
  repeated int64 uids = 1; // v: required
}
message GetUserWithdrawalInfoByUidsReply {
  repeated GetUserWithdrawalInfoByUidsData data = 1;
}
message GetUserWithdrawalInfoByUidsData {
  int64 uid = 1;
  int32 type = 2;
  string open_id = 3;
  string social_avatar = 4;
  string social_nickname = 5;
  string app_id = 6;
  int64 updated_at = 7;
  string extend_1 = 8;
  string extend_2 = 9;
  string extend_3 = 10;
}

执行多次 gf gen pb -p ../user -a rpc -c rpcctl 命令,会导致 标签注入与数据校验 出现多次

What did you see happen?

第一次生成出来的account_grpc.pb.go文件里面的

type GetUserWithdrawalInfoByUidsRequest struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Uids []int64 `protobuf:"varint,1,rep,packed,name=uids,proto3" json:"uids,omitempty" v:"required"` // v: required
}

第二次生成出来的account_grpc.pb.go文件里面的

type GetUserWithdrawalInfoByUidsRequest struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Uids []int64 `protobuf:"varint,1,rep,packed,name=uids,proto3" json:"uids,omitempty" v:"required" v:"required"` // v: required
}

第三次生成出来的account_grpc.pb.go文件里面的

type GetUserWithdrawalInfoByUidsRequest struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Uids []int64 `protobuf:"varint,1,rep,packed,name=uids,proto3" json:"uids,omitempty" v:"required" v:"required" v:"required"` // v: required
}

What did you expect to see?

我希望每次生成出来的都是这样

type GetUserWithdrawalInfoByUidsRequest struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Uids []int64 `protobuf:"varint,1,rep,packed,name=uids,proto3" json:"uids,omitempty" v:"required"` // v: required
}
@wisonlau wisonlau added the bug It is confirmed a bug, but don't worry, we'll handle it. label Nov 20, 2024
@gqcn
Copy link
Member

gqcn commented Nov 21, 2024

It is caused by incorrect regular expression replacement, it would be better using AST instead of regular expression.

@oldme-git Hello big old, do you have some time handling this issue?

Copy link

Hello @wisonlau. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @wisonlau。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。

@wangle201210 wangle201210 self-assigned this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants