On Wed, Nov 11, 2020 at 7:42 AM 'Axel Wagner' via golang-nuts
<
golan...@googlegroups.com> wrote:
>
>
https://play.golang.org/p/qTBiAdR9djt
>
> `a` is the address of the first element of `l`.
> `b` is the address of the first element of `l[0]`, which is of type `[]interface{}` after the assignment.
>
> Both `l` and `l[0]` refer to the same underlying array, so their first elements have the same address.
>
> In practice, you probably want to walk the value with a depth-first search and use `reflect` to extract the addresses and check for slices and the like and use a `map[reflect.Value]bool` with pointers to keep track which values you've already seen. The code isn't trivial enough for me to just write it down at the moment, but once the idea is clear, it should be doable.