Skip to content

Add function to copy struct of amconfig.Config #589

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

Merged
merged 1 commit into from
Oct 31, 2017
Merged

Conversation

lelenanam
Copy link
Contributor

@lelenanam lelenanam commented Oct 31, 2017

Marshal/unmarshal json to deep copy config

@lelenanam
Copy link
Contributor Author

@jpellizzari
Copy link

I created this PR, which does the same thing: #590

@lelenanam 's PR looks nicer. @bboreham Any preference?

@lelenanam
Copy link
Contributor Author

My opinion is this solution is more robust and will work even if we add/change other fields of config or if fields are changing somewhere else in the code but we just haven't noticed it yet.

return newConfig, nil
}

func copyConfig(config *amconfig.Config) (*amconfig.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a comment explaining we need to do a deep copy because of pointers, slices, etc

Marshal/unmarshal json to deep copy config
@jpellizzari jpellizzari merged commit fc21ec2 into master Oct 31, 2017
@lelenanam lelenanam deleted the copyconfig branch October 31, 2017 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants