我對 Go 還是很陌生。是否可以從嵌入式父函數(shù)返回子類型?類似于以下代碼的內(nèi)容:type Humans struct { NextPage string}type Employees struct { Humans Items []struct { Stuff string DifferentStuff float64 } }func (h *Human) Next() interface{} { list interface{} jsonGet(h.NextPage, &list) return list}func main() { list := Employees{} jsonGet("http://blah.blah", &list) for ; list != nil; list = list.Next() { for _, item := range list.Items { ... do stuff ... } }}
- 1 回答
- 0 關(guān)注
- 159 瀏覽
添加回答
舉報
0/150
提交
取消