Skip to content

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

@wisonlau

Description

@wisonlau

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
}

Metadata

Metadata

Assignees

Labels

bugIt is confirmed a bug, but don't worry, we'll handle it.help wanted

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions