[go] mime: add ExtensionByType method

181 views
Skip to first unread message

Nick Cooper (Gerrit)

unread,
Mar 11, 2015, 8:25:02 PM3/11/15
to Ian Lance Taylor, golang-co...@googlegroups.com
Nick Cooper uploaded a change:
https://go-review.googlesource.com/7444

mime: add ExtensionByType method

Added the inverse of TypeByExtension for discovering an appropriate
extension for a given MIME type. In cases where there are multiple
such extensions, it opts for the shortest.

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
---
M src/mime/type.go
M src/mime/type_test.go
2 files changed, 54 insertions(+), 2 deletions(-)



diff --git a/src/mime/type.go b/src/mime/type.go
index ffda1f0..428b899 100644
--- a/src/mime/type.go
+++ b/src/mime/type.go
@@ -24,7 +24,8 @@
".png": "image/png",
".xml": "text/xml; charset=utf-8",
}
- mimeTypes = clone(mimeTypesLower)
+ mimeTypes = clone(mimeTypesLower)
+ extensions = invert(mimeTypesLower)
)

func clone(m map[string]string) map[string]string {
@@ -34,6 +35,21 @@
if strings.ToLower(k) != k {
panic("keys in mimeTypesLower must be lowercase")
}
+ }
+ return m2
+}
+
+func invert(m map[string]string) map[string]string {
+ m2 := make(map[string]string, len(m))
+ for k, v := range m {
+ justType, _, err := ParseMediaType(v)
+ if err != nil {
+ panic(err)
+ }
+ if existing, ok := m2[justType]; ok && len(existing) < len(k) {
+ continue
+ }
+ m2[justType] = k
}
return m2
}
@@ -91,6 +107,23 @@
return mimeTypesLower[string(lower)]
}

+// ExtensionByType returns the shortest extension known to be associated
with
+// the MIME type typ. The returned extension will begin with a leading
dot, as
+// in ".htm". When typ has no associated extension, ExtensionByType
returns "".
+//
+// The built-in table is the same as used with TypeByExtension.
+func ExtensionByType(typ string) (string, error) {
+ justType, _, err := ParseMediaType(typ)
+ if err != nil {
+ return "", err
+ }
+
+ once.Do(initMime)
+ mimeLock.RLock()
+ defer mimeLock.RUnlock()
+ return extensions[justType], nil
+}
+
// AddExtensionType sets the MIME type associated with
// the extension ext to typ. The extension should begin with
// a leading dot, as in ".html".
@@ -103,7 +136,7 @@
}

func setExtensionType(extension, mimeType string) error {
- _, param, err := ParseMediaType(mimeType)
+ justType, param, err := ParseMediaType(mimeType)
if err != nil {
return err
}
@@ -116,6 +149,9 @@
mimeLock.Lock()
mimeTypes[extension] = mimeType
mimeTypesLower[extLower] = mimeType
+ if existing, ok := extensions[justType]; !ok || len(existing) >
len(extLower) {
+ extensions[justType] = extLower
+ }
mimeLock.Unlock()
return nil
}
diff --git a/src/mime/type_test.go b/src/mime/type_test.go
index d2d254a..93bb315 100644
--- a/src/mime/type_test.go
+++ b/src/mime/type_test.go
@@ -5,6 +5,7 @@
package mime

import (
+ "strings"
"testing"
)

@@ -43,6 +44,21 @@
}
}

+func TestExtensionByType(t *testing.T) {
+ for want, typ := range typeTests {
+ val, err := ExtensionByType(typ)
+ if err != nil {
+ t.Errorf("ExtensionByType(%q) gave error %q", typ, err)
+ continue
+ }
+ // We always expect lower case, test data includes upper-case.
+ want = strings.ToLower(want)
+ if val != want {
+ t.Errorf("ExtensionByType(%q) = %q, want %q", typ, val, want)
+ }
+ }
+}
+
func TestLookupMallocs(t *testing.T) {
n := testing.AllocsPerRun(10000, func() {
TypeByExtension(".html")

--
https://go-review.googlesource.com/7444

Josh Bleecher Snyder (Gerrit)

unread,
Mar 11, 2015, 10:34:26 PM3/11/15
to Nick Cooper, golang-co...@googlegroups.com
Josh Bleecher Snyder has posted comments on this change.

mime: add ExtensionByType method

Patch Set 1:

Why is this needed?

I'd recommend filing an issue first to explain context, discuss
appropriateness and design, etc. Thanks!

--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-HasComments: No

Nick Cooper (Gerrit)

unread,
Mar 11, 2015, 10:58:59 PM3/11/15
to Josh Bleecher Snyder, golang-co...@googlegroups.com
Nick Cooper uploaded a new patch set:
https://go-review.googlesource.com/7444

mime: add ExtensionByType method

Added the inverse of TypeByExtension for discovering an appropriate
extensions for a given MIME type.

Fixes #10144

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
---
M src/mime/type.go
M src/mime/type_test.go
2 files changed, 75 insertions(+), 2 deletions(-)

Nick Cooper (Gerrit)

unread,
Mar 11, 2015, 10:59:34 PM3/11/15
to Josh Bleecher Snyder, golang-co...@googlegroups.com
Nick Cooper has posted comments on this change.

mime: add ExtensionByType method

Patch Set 2:

Done, https://github.com/golang/go/issues/10144

Also linked to that from here in-case this is indeed the decided-upon route.

--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-HasComments: No

Andrew Gerrand (Gerrit)

unread,
Mar 11, 2015, 11:09:24 PM3/11/15
to Nick Cooper, Josh Bleecher Snyder, golang-co...@googlegroups.com
Andrew Gerrand has posted comments on this change.

mime: add ExtensionByType method

Patch Set 2:

(3 comments)

https://go-review.googlesource.com/#/c/7444/2/src/mime/type.go
File src/mime/type.go:

Line 109: // ".htm". When typ has no associated extension, ExtensionsByType
returns an
please use ".html"


Line 112: // The mapping is the same as used with TypeByExtension.
This line is unnecessary and may be confusing as ExtensionsByType will sort
before TypesByExtension.


Line 122: return append([]string{}, extensions[justType]...), nil
I'd prefer to return nil instead of an empty slice:

s, ok := extensions[justType]
if !ok {
return nil, nil
}
return append([]string{}, s...), nil

and you should mention the "not found" case in the doc comment.


--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-HasComments: Yes

Nick Cooper (Gerrit)

unread,
Mar 11, 2015, 11:13:31 PM3/11/15
to Josh Bleecher Snyder, Andrew Gerrand, golang-co...@googlegroups.com
Nick Cooper has posted comments on this change.

mime: add ExtensionByType method

Patch Set 2:

(3 comments)

https://go-review.googlesource.com/#/c/7444/2/src/mime/type.go
File src/mime/type.go:

Line 109: // ".htm". When typ has no associated extension, ExtensionsByType
returns an
> please use ".html"
Done


Line 112: // The mapping is the same as used with TypeByExtension.
> This line is unnecessary and may be confusing as ExtensionsByType will
> sort
Removed it [based on 'unnecessary'], but do you think I should instead
duplicate the documentation and/or move to the package description?


Line 122: return append([]string{}, extensions[justType]...), nil
> I'd prefer to return nil instead of an empty slice:
Done. Also, I do mention it [last sentence]

Nick Cooper (Gerrit)

unread,
Mar 11, 2015, 11:13:32 PM3/11/15
to Andrew Gerrand, Josh Bleecher Snyder, golang-co...@googlegroups.com
Nick Cooper uploaded a new patch set:
https://go-review.googlesource.com/7444

mime: add ExtensionByType method

Added the inverse of TypeByExtension for discovering an appropriate
extensions for a given MIME type.

Fixes #10144

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
---
M src/mime/type.go
M src/mime/type_test.go
2 files changed, 77 insertions(+), 2 deletions(-)

Andrew Gerrand (Gerrit)

unread,
Mar 11, 2015, 11:18:39 PM3/11/15
to Nick Cooper, Josh Bleecher Snyder, golang-co...@googlegroups.com
Andrew Gerrand has posted comments on this change.

mime: add ExtensionByType method

Patch Set 3: Code-Review+1

(1 comment)

Looks good to me, but I'd like to get someone else to sign off on this

https://go-review.googlesource.com/#/c/7444/3/src/mime/type.go
File src/mime/type.go:

Line 110: // empty slice.
it now returns a nil slice :)


--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-HasComments: Yes

Nick Cooper (Gerrit)

unread,
Mar 11, 2015, 11:20:31 PM3/11/15
to Andrew Gerrand, Rob Pike, Josh Bleecher Snyder, golang-co...@googlegroups.com
Reviewers: Andrew Gerrand

Nick Cooper uploaded a new patch set:
https://go-review.googlesource.com/7444

mime: add ExtensionByType method

Added the inverse of TypeByExtension for discovering an appropriate
extensions for a given MIME type.

Fixes #10144

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
---
M src/mime/type.go
M src/mime/type_test.go
2 files changed, 77 insertions(+), 2 deletions(-)


--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-Reviewer: Rob Pike <r...@golang.org>

Nick Cooper (Gerrit)

unread,
Mar 11, 2015, 11:20:35 PM3/11/15
to Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, golang-co...@googlegroups.com
Nick Cooper has posted comments on this change.

mime: add ExtensionByType method

Patch Set 3:

(1 comment)

https://go-review.googlesource.com/#/c/7444/3/src/mime/type.go
File src/mime/type.go:

Line 110: // empty slice.
> it now returns a nil slice :)
Ah, I see. I wasn't sure if we were to 'encourage' the idea of nil vs.
empty.


--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-Reviewer: Rob Pike <r...@golang.org>
Gerrit-HasComments: Yes

Andrew Gerrand (Gerrit)

unread,
Mar 11, 2015, 11:23:08 PM3/11/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, golang-co...@googlegroups.com
Andrew Gerrand has posted comments on this change.

mime: add ExtensionByType method

Patch Set 3:

(1 comment)

https://go-review.googlesource.com/#/c/7444/3/src/mime/type.go
File src/mime/type.go:

Line 110: // empty slice.
> Ah, I see. I wasn't sure if we were to 'encourage' the idea of nil vs.
> empt
We shouldn't encourage programming around it, but we should always be
accurate.

Nick Cooper (Gerrit)

unread,
Mar 18, 2015, 4:01:36 PM3/18/15
to Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, golang-co...@googlegroups.com
Nick Cooper has posted comments on this change.

mime: add ExtensionByType method

Patch Set 3:

(1 comment)

https://go-review.googlesource.com/#/c/7444/3/src/mime/type.go
File src/mime/type.go:

Line 110: // empty slice.
> We shouldn't encourage programming around it, but we should always be
> accur
Done

Brad Fitzpatrick (Gerrit)

unread,
Mar 23, 2015, 7:38:26 PM3/23/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, golang-co...@googlegroups.com
Brad Fitzpatrick has posted comments on this change.

mime: add ExtensionByType method

Patch Set 4:

(2 comments)

https://go-review.googlesource.com/#/c/7444/4/src/mime/type_test.go
File src/mime/type_test.go:

Line 55: t.Errorf("ExtensionsByType(%q) = %v, want 1", typ, len(val))
it doesn't equal len(val). It contains len(val) items. I'd say something
like:

Errorf("ExtensionByType(%q) = %v; expected exactly 1 entry", typ, val)


Line 73: for _, ext := range exts {
How about just:

const typ = "text/html"
exts, err := ExtensionsByType(typ)
if err != nil {
t.Fatalf("ExtensionByType(%q) error: %v", typ, err)
}
sort.Strings(exts)
if want := []string{".htm", ".html"}; !reflect.DeepEqual(exts, want) {
t.Errorf("ExtensionsByType(%q) = %v; want %v", typ, exts, want)
}


--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>

Nick Cooper (Gerrit)

unread,
Mar 23, 2015, 8:22:15 PM3/23/15
to Andrew Gerrand, Brad Fitzpatrick, Rob Pike, Josh Bleecher Snyder, golang-co...@googlegroups.com
Reviewers: Andrew Gerrand

Nick Cooper uploaded a new patch set:
https://go-review.googlesource.com/7444

mime: add ExtensionByType method

Added the inverse of TypeByExtension for discovering an appropriate
extensions for a given MIME type.

Fixes #10144

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
---
M src/mime/type.go
M src/mime/type_test.go
2 files changed, 70 insertions(+), 2 deletions(-)

Nick Cooper (Gerrit)

unread,
Mar 23, 2015, 8:22:59 PM3/23/15
to Josh Bleecher Snyder, Rob Pike, Brad Fitzpatrick, Andrew Gerrand, golang-co...@googlegroups.com
Nick Cooper has posted comments on this change.

mime: add ExtensionByType method

Patch Set 4:

(2 comments)

https://go-review.googlesource.com/#/c/7444/4/src/mime/type_test.go
File src/mime/type_test.go:

Line 55: t.Errorf("ExtensionsByType(%q) = %v, want 1", typ, len(val))
> it doesn't equal len(val). It contains len(val) items. I'd say something
Done


Line 73: for _, ext := range exts {
> How about just:
Done


--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-Reviewer: Rob Pike <r...@golang.org>
Gerrit-HasComments: Yes

Brad Fitzpatrick (Gerrit)

unread,
Mar 27, 2015, 5:51:44 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, golang-co...@googlegroups.com
Brad Fitzpatrick has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5: Code-Review+2 Run-TryBot+1

--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-Reviewer: Rob Pike <r...@golang.org>
Gerrit-HasComments: No

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 5:52:19 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5:

TryBots beginning. Status page: http://farmer.golang.org/try?commit=46b447c6

--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Reviewer: Gobot Gobot <go...@golang.org>

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 5:59:35 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5:

This change failed on windows-amd64-gce:
See
https://storage.googleapis.com/go-build-log/46b447c6/windows-amd64-gce_bee7b465.log

Consult https://build.golang.org/ to see whether it's a new failure.

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 5:59:45 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5:

This change failed on windows-386-gce:
See
https://storage.googleapis.com/go-build-log/46b447c6/windows-386-gce_6f377a8f.log

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 6:00:48 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5:

This change failed on nacl-amd64p32:
See
https://storage.googleapis.com/go-build-log/46b447c6/nacl-amd64p32_e97c0be9.log

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 6:00:52 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5:

This change failed on nacl-386:
See
https://storage.googleapis.com/go-build-log/46b447c6/nacl-386_8aa37b26.log

Brad Fitzpatrick (Gerrit)

unread,
Mar 27, 2015, 6:04:16 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Gobot Gobot, Andrew Gerrand, golang-co...@googlegroups.com
Brad Fitzpatrick has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5: -Code-Review

Some of the failures will go away when you rebase, but some look real, like
Windows:

--- FAIL: TestExtensionsByType (0.00s)
type_test.go:57: ExtensionsByType("image/png") = [.png .png]; expected
exactly 1 entry
--- FAIL: TestExtensionsByTypeMultiple (0.00s)
type_test.go:76: ExtensionsByType("text/html") = [.htm .htm .html .html];
want [.htm .html]
FAIL


Please fix.

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 6:10:44 AM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 5: TryBot-Result-1

4 of 12 TryBots failed: windows-amd64-gce, windows-386-gce, nacl-amd64p32,
nacl-386

Nick Cooper (Gerrit)

unread,
Mar 27, 2015, 11:31:51 AM3/27/15
to Gobot Gobot, Brad Fitzpatrick, Andrew Gerrand, Rob Pike, Josh Bleecher Snyder, golang-co...@googlegroups.com
Reviewers: Gobot Gobot, Brad Fitzpatrick, Andrew Gerrand

Nick Cooper uploaded a new patch set:
https://go-review.googlesource.com/7444

mime: add ExtensionByType method

Added the inverse of TypeByExtension for discovering an appropriate
extensions for a given MIME type.

Fixes #10144

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
---
M src/mime/type.go
M src/mime/type_test.go
2 files changed, 98 insertions(+), 3 deletions(-)

Nick Cooper (Gerrit)

unread,
Mar 27, 2015, 11:33:24 AM3/27/15
to Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, Gobot Gobot, golang-co...@googlegroups.com
Nick Cooper has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6:

Quite right, I forgot to consider duplicates (apparently not an issue on
Linux). Have fixed and added a new test, PTAL

--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Reviewer: Gobot Gobot <go...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-Reviewer: Rob Pike <r...@golang.org>
Gerrit-HasComments: No

Brad Fitzpatrick (Gerrit)

unread,
Mar 27, 2015, 12:15:01 PM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Gobot Gobot, golang-co...@googlegroups.com
Brad Fitzpatrick has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6: Run-TryBot+1

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 12:15:26 PM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6:

TryBots beginning. Status page: http://farmer.golang.org/try?commit=11dab5f7

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 12:22:02 PM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6:

This change failed on windows-amd64-gce:
See
https://storage.googleapis.com/go-build-log/11dab5f7/windows-amd64-gce_b2559166.log

Consult https://build.golang.org/ to see whether it's a new failure.

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 12:22:49 PM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6:

This change failed on windows-386-gce:
See
https://storage.googleapis.com/go-build-log/11dab5f7/windows-386-gce_86d1af64.log

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 12:23:33 PM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6:

This change failed on nacl-amd64p32:
See
https://storage.googleapis.com/go-build-log/11dab5f7/nacl-amd64p32_5d4e2d8b.log

Gobot Gobot (Gerrit)

unread,
Mar 27, 2015, 12:23:35 PM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Brad Fitzpatrick, golang-co...@googlegroups.com
Gobot Gobot has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6:

This change failed on nacl-386:
See
https://storage.googleapis.com/go-build-log/11dab5f7/nacl-386_20a977ea.log

Brad Fitzpatrick (Gerrit)

unread,
Mar 27, 2015, 12:24:05 PM3/27/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Gobot Gobot, golang-co...@googlegroups.com
Brad Fitzpatrick has posted comments on this change.

mime: add ExtensionByType method

Patch Set 6: Code-Review+2

Brad Fitzpatrick (Gerrit)

unread,
Mar 27, 2015, 12:24:12 PM3/27/15
to Nick Cooper, golang-...@googlegroups.com, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Gobot Gobot, golang-co...@googlegroups.com
Brad Fitzpatrick has submitted this change and it was merged.

mime: add ExtensionByType method

Added the inverse of TypeByExtension for discovering an appropriate
extensions for a given MIME type.

Fixes #10144

Change-Id: I6a80e1af3db5d45ad6a4c7ff4ccfdf6a4f424367
Reviewed-on: https://go-review.googlesource.com/7444
Run-TryBot: Brad Fitzpatrick <brad...@golang.org>
Reviewed-by: Brad Fitzpatrick <brad...@golang.org>
---
M src/mime/type.go
M src/mime/type_test.go
2 files changed, 98 insertions(+), 3 deletions(-)

Approvals:
Brad Fitzpatrick: Looks good to me, approved; Run TryBots

Brad Fitzpatrick (Gerrit)

unread,
Mar 28, 2015, 5:40:03 AM3/28/15
to Nick Cooper, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Gobot Gobot, golang-co...@googlegroups.com
Brad Fitzpatrick has posted comments on this change.

mime: add ExtensionByType method

Patch Set 7:

Nick, this is causing test failures for people, even after the Windows fix.
See https://github.com/golang/go/issues/10278

--
https://go-review.googlesource.com/7444
Gerrit-Reviewer: Andrew Gerrand <a...@golang.org>
Gerrit-Reviewer: Brad Fitzpatrick <brad...@golang.org>
Gerrit-Reviewer: Gobot Gobot <go...@golang.org>
Gerrit-Reviewer: Josh Bleecher Snyder <josh...@gmail.com>
Gerrit-Reviewer: Nick Cooper <nm...@google.com>
Gerrit-Reviewer: Rob Pike <r...@golang.org>
Gerrit-HasComments: No

Nick Cooper ☯

unread,
Mar 28, 2015, 11:55:00 AM3/28/15
to brad...@golang.org, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Gobot Gobot, golang-co...@googlegroups.com

Unsure on procedure here, rollback or patch?

In either case I'm out until Monday Pacific time.

Brad Fitzpatrick

unread,
Mar 29, 2015, 11:15:18 AM3/29/15
to Nick Cooper ☯, Josh Bleecher Snyder, Rob Pike, Andrew Gerrand, Gobot Gobot, golang-co...@googlegroups.com
We can roll forward instead and fix soon. If the builders were broken I'd say roll back, but the main Windows builders are fine. I left comments on Github about what needs to be done.

Reply all
Reply to author
Forward
0 new messages