github.com/traefik/yaegi@v0.15.1/_test/struct51.go (about) 1 package main 2 3 import ( 4 "encoding/json" 5 "os" 6 ) 7 8 type Node struct { 9 Name string 10 Child [2]*Node 11 } 12 13 func main() { 14 a := Node{Name: "hello"} 15 a.Child[0] = &Node{Name: "world"} 16 json.NewEncoder(os.Stdout).Encode(a) 17 a.Child[0].Child[0] = &Node{Name: "sunshine"} 18 json.NewEncoder(os.Stdout).Encode(a) 19 } 20 21 // Output: 22 // {"Name":"hello","Child":[{"Name":"world","Child":[null,null]},null]} 23 // {"Name":"hello","Child":[{"Name":"world","Child":[{"Name":"sunshine","Child":[null,null]},null]},null]}