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

If it does not end with a json tag, omitempty cannot be removed after executing inject_tag. #60

Open
ghost opened this issue Nov 20, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Nov 20, 2023

Automatically generate pb files based on table structure:

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

	// @inject_tag: orm:"id,primary"
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" orm:"id,primary"` //
	// @inject_tag: orm:"name"
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" orm:"name"` // gift name
	// @inject_tag: orm:"app_id"
	AppId uint32 `protobuf:"varint,3,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" orm:"app_id"` // app ID
	// @inject_tag: orm:"is_combo"
	IsCombo uint32 `protobuf:"varint,4,opt,name=is_combo,json=isCombo,proto3" json:"is_combo,omitempty" orm:"is_combo"` // combo gift. 0:no,1:yes
}

expect:

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

	// @inject_tag: orm:"id,primary"
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id" orm:"id,primary"` //
	// @inject_tag: orm:"name"
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name" orm:"name"` // gift name
	// @inject_tag: orm:"app_id"
	AppId uint32 `protobuf:"varint,3,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" orm:"app_id"` // app ID
	// @inject_tag: orm:"is_combo"
	IsCombo uint32 `protobuf:"varint,4,opt,name=is_combo,json=isCombo,proto3" json:"is_combo" orm:"is_combo"` // combo gift. 0:no,1:yes
}

===============================================

But can be parsed normally in custom struct:

message UserVip {
  // @inject_tag: json:"unlock"
  uint32 unlock = 1;//show_tab=vip, Unlock required level
  // @inject_tag: json:"state"
  uint32 state = 2; //state. 0:not unlock,1: unlock already
}

output:

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

	// @inject_tag: json:"unlock"
	Unlock uint32 `protobuf:"varint,1,opt,name=unlock,proto3" json:"unlock"` //show_tab=vip, Unlock required level
	// @inject_tag: json:"state"
	State uint32 `protobuf:"varint,2,opt,name=state,proto3" json:"state"` //state. 0:not unlock,1: unlock already
}
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

0 participants