You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -7,3 +7,79 @@ This package is a Golang implementation for creating deep copies of virtually an
7
7
This is a truly deep copy--every single value behind a pointer, every item in a slice or array, and every key and value in a map are all cloned so nothing is pointing to what it pointed to before.
8
8
9
9
To handle circular pointer references (e.g. a pointer to a struct with a pointer field that points back to the original struct), we keep track of a map of pointers that have already been visited. This serves two purposes. First, it keeps us from getting into any kind of infinite loop. Second, it ensures that the code will behave similarly to how it would have on the original struct -- if you expect two values to be pointing at the same value within the copied tree, then they'll both still point to the same thing.
_Note that the values are all the same, but the addresses are all different.
69
+
Note also that circular dependencies are handled--the self-referential Foo remains self-referential within each instance, but different across copies._
0 commit comments