[go-nuts] detecting cyclic references

2020-11-09 Thread arpad ryszka
Hi, is there a way to detect the cyclic reference in the following example somehow? Either via reflection or by other means? My understanding is that slices cannot be compared with == (unless to nil), or used as keys in maps. Is there a different way? l := []interface{}{"foo"} l[0] = l fmt.Pri

Re: [go-nuts] detecting cyclic references

2020-11-11 Thread arpad ryszka
: >> >>> If the slice is empty, it doesn't reference anything. >>> If it is not empty, &x[0] can be used to identify the slice (potentially >>> also using len/cap, if it's interesting). >>> >>> On Tue, Nov 10, 2020 at 4:11 AM arpad r

Re: [go-nuts] detecting cyclic references

2020-11-22 Thread arpad ryszka
Thanks a lot for the help! Seems like I could sort it out based on the reflect.DeepEqual code. Do you have any testing tips? Out of general curiosity, I am wondering why the type is part of the key for the visited map here: https://golang.org/src/reflect/deepequal.go#L15. If I remove it, the te