What does "shallow clone" mean?

115 views
Skip to first unread message

shinya sakae

unread,
Aug 11, 2023, 10:28:23 AM8/11/23
to golang-nuts
maps package was released with Go 1.21.
Clone() comment says "This is a shallow clone".
I often hear the term `shallow copy', but I don't know what `shallow clone` means.
What is the state of a `shallow cloned` map?
Do you mean that the cloned map values are shallow copied?

Ian Lance Taylor

unread,
Aug 11, 2023, 10:36:50 AM8/11/23
to shinya sakae, golang-nuts
Yes.

Ian

TheDiveO

unread,
Aug 11, 2023, 12:14:49 PM8/11/23
to golang-nuts
Personally, I find the source https://cs.opensource.google/go/x/exp/+/352e893a:maps/maps.go;l=65 to be helpful in quickly answering such questions.

shinya sakae

unread,
Aug 11, 2023, 6:05:18 PM8/11/23
to golang-nuts
Many thanks!

2023年8月12日土曜日 1:14:49 UTC+9 TheDiveO:
Reply all
Reply to author
Forward
0 new messages