-
Notifications
You must be signed in to change notification settings - Fork 34
Primitive copy on maps #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
enderv
wants to merge
3
commits into
globusdigital:master
Choose a base branch
from
enderv:primitive-copy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -390,7 +390,10 @@ func walkType(source, sink, x string, m types.Type, w io.Writer, imports map[str | |
| fmt.Fprintf(w, ` for %s := range %s { | ||
| `, idx, source) | ||
|
|
||
| b.WriteTo(w) | ||
| _, err := b.WriteTo(w) | ||
| if err != nil { | ||
| fmt.Println(err) | ||
| } | ||
|
|
||
| fmt.Fprintf(w, "}\n") | ||
| } | ||
|
|
@@ -456,7 +459,11 @@ func walkType(source, sink, x string, m types.Type, w io.Writer, imports map[str | |
| if b.Len() > 0 { | ||
| ksink = copyKSink | ||
| fmt.Fprintf(w, "var %s %s\n", ksink, kkind) | ||
| b.WriteTo(w) | ||
| fmt.Fprintf(w, "%s = %s\n", ksink, source) | ||
| _, err := b.WriteTo(w) | ||
| if err != nil { | ||
| fmt.Println(err) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -469,7 +476,11 @@ func walkType(source, sink, x string, m types.Type, w io.Writer, imports map[str | |
| if b.Len() > 0 { | ||
| vsink = copyVSink | ||
| fmt.Fprintf(w, "var %s %s\n", vsink, vkind) | ||
| b.WriteTo(w) | ||
| fmt.Fprintf(w, "%s = %s\n", vsink, val) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as the above |
||
| _, err := b.WriteTo(w) | ||
| if err != nil { | ||
| fmt.Println(err) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. could you tell me what the idea behind this line is? It looks like it would copy the pointer map to a new variable, but if that's the case I don't think we should be doing that, since we want copy the individual keys and values in the map itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the quick reply! Sorry for lack of initial explanation: What I found was on nested custom structs it would handle maps/slices ok but not any primitive types when it got to the bottom of the map. If I run deep-copy code for each individual type it would work ok but as we have a very complex type I did not want other devs to have to always remember to generate for each new one that (they might not even know its embedded).
Now that you called it out though I don't think this is working as expected either as if any pointer types it would not work correctly (just don't have any in our struct so missed it) will circle back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we'll need to somehow keep and satisfy the change in main_test.go:295, but discard the rest of the test changes and make sure that no other test cases are affected