我可能以错误的方式进行,但我想定义两个或多个结构(消息)之间的关系。
以堆栈溢出为例,假设我对标签有一个用于 CRUD 的操作。我也有一个地方可以有.让我们也假设我有一个和一个也可以附加标签LabelServiceQuestionServiceQuestionLabelsUserServiceUser
# label.proto
service LabelService {
rpc CreateLabel() returns();
...etc
}
message Label {
string text = 1;
}
但现在我想创建我的和消息。我是否将这两个文件关联到 go 代码中如何或完成此级别的关联?QuestionServiceQuestion
# question.proto
service QuestionService {
rpc CreateQuestion() returns();
...etc
}
message Question {
string text = 1;
repeat Label labels = 2 # <-- how to do this?
}
# user.proto
service UserService {
rpc CreateQuestion() returns();
...etc
}
message User {
string name = 1;
repeat Label labels = 2 # <-- how to do this?
}
我想我感到困惑,因为对于REST API和使用 gorm.io 例如,我会在结构中设置关联,并让 gorm.io 创建表。
阿晨1998
饮歌长啸
相关分类