1

2023/08/23 15:24:39 C:/Code/vblog/skill/rpc/protobuf/blog/impl/blog.go:19 [error] invalid field found for struct protobuf/blog.Blog's field Meta: define a valid foreign key for relations or implement the Valuer/Scanner interface

message Meta {
    int64 id = 1;
    int64 created_at = 2;
    int64 updated_at = 3;
}
message Blog {
    // @gotags: gorm:"embedded" json:"meta" bson:",inline"
    Meta meta = 1;
    // 具体请求数据
    CreateBlogRequest spec = 2;
}
func NewMeta() *Meta {
    return &Meta{CreatedAt: time.Now().Unix()}
}

func NewBlog(req *CreateBlogRequest) *Blog {
    return &Blog{Meta: NewMeta(), Spec: req}
}
type Blog struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    // @gotags: gorm:"embedded" json:"meta" bson:",inline"
    Meta *Meta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"`
    // 具体请求数据
    Spec *CreateBlogRequest `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"`
}
ssxszt
  • 11
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – AthulMuralidhar Aug 25 '23 at 10:57

0 Answers0