-2
저는 아직 이동이 상당히 새롭습니다.부모 함수에서 자식 유형 반환
임베디드 부모 함수에서 자식 유형을 반환 할 수 있습니까? 다음 코드의 라인을 따라
뭔가 :
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 ...
}
}
}
요구 사항을 자세히 설명해 주실 수 있습니까? –