Skip to content
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

mime: FormatMediaType inconsistent results #8115

Closed
gopherbot opened this issue May 28, 2014 · 3 comments
Closed

mime: FormatMediaType inconsistent results #8115

gopherbot opened this issue May 28, 2014 · 3 comments

Comments

@gopherbot
Copy link

by anton.hendriks:

After switching to the go 1.3 beta mime.FormatMediaType has started giving inconsistent
results. This is obviously a result of the map parameter and up till now we've just been
lucky to pass small enough maps that haven't been randomized.

The function produces output from a long chain of processing and having the output
consistent simplifies testing considerably. We usually solve this problem by iterating
over a sorted list of the map keys rather than the map itself.

Proposed fix. Replace line 34 of src/pkg/mime/mediatype.go with the following.

        attributes := make([]string, 0, len(param))
    for a, _ := range param {
        attributes = append(attributes, a)
    }
    sort.Strings(attributes)

    for attribute, _ := range attributes {
        value := param[attribute]
@bradfitz
Copy link
Contributor

Comment 1:

Sent https://golang.org/cl/98580047 for review.

Labels changed: added repo-main.

Owner changed to @bradfitz.

Status changed to Started.

@gopherbot
Copy link
Author

Comment 2:

CL https://golang.org/cl/98580047 mentions this issue.

@bradfitz
Copy link
Contributor

Comment 3:

This issue was closed by revision ef25861.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Map iteration order issue. Go 1.2 and earlier had stable results
for small maps.

Fixes golang#8115

LGTM=r, rsc
R=golang-codereviews, r
CC=dsymonds, golang-codereviews, iant, rsc
https://golang.org/cl/98580047
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants