Use pointers.

https://go.dev/play/p/V9M_XxX052J

On Friday, 3 March 2023 at 13:18:30 UTC BARIKUMA MONDELO wrote:

> Is it possible to have two structs both declared in each other, something 
> like this
>
> type human struct {
>         name string
>         age int
>         address Address
> }
>
> type Address struct {
>         country, city string
>         postalCode uint
>         human
> }
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/eb65bc25-6b3d-4bbb-80d3-af9bd18b3400n%40googlegroups.com.

Reply via email to