#718·go

Bug:Dead Loop Two when Two structs are mutually dependent。

Author: jau1jzCreated Nov 20, 2025Updated Nov 20, 2025

package main

import ( "log"

json "github.com/json-iterator/go"

)

// Implement interface type Address struct { City string State string Post string *Person }

// Implement interface type Person struct { Name string Age int *Address }

func main() { A := Address{ City: "New York", State: "NY", } p := Person{ Name: "Alice", Age: 30, Address: &A, } A.Person = &p

marshal, err := json.Marshal(&p)
if err != nil {
	log.Printf("Marshal failed: %v", err)
} else {
	log.Printf("format: %s", marshal)
}

}

Address include Person Point Person include Address Point json "github.com/json-iterator/go"

Use"encoding/json"