-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Updating api_installer to register paths in a deterministic order to get a deterministic swagger spec #5426
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
…get a deterministic swagger spec
// Register the paths in a deterministic (sorted) order to get a deterministic swagger spec. | ||
paths := make([]string, len(a.group.Storage)) | ||
var i int = 0 | ||
for path := range a.group.Storage { |
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.
Why not:
for i, path := range a.group.Storage {
? Since this is really a projection function?
You don't need to change it -- I thought I would just ask.
Another pattern is paths := []string{}
and then paths = append(paths, path)
but what you have written is perhaps a little better for allocation.
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.
IIUC, That will not work because a.group.Storage is a map. There is no concept of an index in a map.
for i, path := range a.group.Storage {
will give me the key in i and value in path.
Regarding using
paths := []string{}
paths = append(paths, path)
Yes. What I have, I believe, is better for allocation.
Also, why do you get the cla:no tag? |
Re. CLA: because @nikhiljindal didn't join the https://github.com/google org. |
I did join that org. I see the Google badge on my profile and I see my name there in "people" section of the group. |
Updating api_installer to register paths in a deterministic order to get a deterministic swagger spec
Fixing our code for #5425