protoc-go-inject-tag
protoc-go-inject-tag copied to clipboard
delete the correct comment -remove_tag_comment
The -remove_tag_comment
parameter will cause the correct comment to be deleted as well.
eg:
message Result {
string ruleCode = 1; // @gotags: json:"rule_code" rule code
string desc = 2; // rule code are explained in detail
}
command:
protoc-go-inject-tag -remove_tag_comment -input=./test/v1/rule.pb.go;
output
type CheckReply_Result struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RuleCode string `protobuf:"bytes,1,opt,name=ruleCode,proto3" json:"rule_code"`
Desc string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // rule code are explained in detail
}
expect output
type CheckReply_Result struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RuleCode string `protobuf:"bytes,1,opt,name=ruleCode,proto3" json:"rule_code"` // rule code
Desc string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // rule code are explained in detail
}
how to solve this。
Thanks to the author
you can use that:
eg:
message Result {
// rule code
string ruleCode = 1; // @gotags: json:"rule_code"
// rule code are explained in detail
string desc = 2;
}
command:
protoc-go-inject-tag -remove_tag_comment -input=./test/v1/rule.pb.go;
output
type CheckReply_Result struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// rule code
RuleCode string `protobuf:"bytes,1,opt,name=ruleCode,proto3" json:"rule_code"`
// rule code are explained in detail
Desc string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
}
This method can be recognized by swagger and openapi.