1 回答

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超1個(gè)贊
您可能需要將這些內(nèi)部結(jié)構(gòu)定義為類型。這有效:
type Page struct {
Description string
PageNumber int
Source string
}
type Chapter struct {
Name string
PageNum int
Pages []Page
}
type Initial_Load struct {
Chapters []Chapter
NumChapters int
}
var x Initial_Load = Initial_Load{
Chapters: []Chapter{
{
Name: "abc",
PageNum: 3,
Pages: []Page{
{
Description: "def",
PageNumber: 3,
Source: "xyz",
},
{
Description: "qrs",
PageNumber: 5,
Source: "xxx",
},
},
},
},
NumChapters: 1,
}
我只放了 1 章,但你明白了。
- 1 回答
- 0 關(guān)注
- 144 瀏覽
添加回答
舉報(bào)