0
我有2層結構,其中一個繼承是常見的由type Common struct {...}
轉到:如何引用一個字段中的繼承結構
type Common struct{
Id int
CreatedAt time.Time
UpdatedAt time.Time
CreatorId int
}
type Post struct{
type Post struct{
Common
Status
Title string
ShortDescription string
Content string
CategoryIds []int
TagIds []int
Url string
MainImageId int
Keywords []string
}
表示所有stucts當中值然而,當我嘗試創建後的新實例結構如下所示。
post1 := &Post{
CreatorId: 1,
Status: 1,
Title: "this is the title of the first post",
ShortDescription: "this is the short description of this post",
Content: "",
Url: "first-post",
MainImageId: 1,
}
它不承認CreatorId
字段。 如何在新實例中引用此字段或修改結構,以便將CreatorID
註冊爲Post
結構的一部分? 由於