]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/get: make the implementation of charsetReader match its comment
authorBryan C. Mills <bcmills@google.com>
Mon, 5 Aug 2019 18:32:46 +0000 (14:32 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 11 Sep 2019 16:24:33 +0000 (16:24 +0000)
The doc comment for charsetReader claims that it supports UTF-8,
but in practice it does not: instead, it is never invoked for UTF-8.

We could update the comment to clarify that fact, but it seems simpler
to change the implementation to match the comment.

Change-Id: I39b11395ccef3feff96480b9294e8f2a232728dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/189777
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/internal/get/discovery.go

index 6ba5c091e39f07b3847df167fa990ebed7d77582..aa2a24d12f310604a75a6cce8c3c6f19052152d7 100644 (file)
@@ -11,15 +11,15 @@ import (
        "strings"
 )
 
-// charsetReader returns a reader for the given charset. Currently
-// it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful
+// charsetReader returns a reader that converts from the given charset to UTF-8.
+// Currently it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful
 // error which is printed by go get, so the user can find why the package
 // wasn't downloaded if the encoding is not supported. Note that, in
 // order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters
 // greater than 0x7f are not rejected).
 func charsetReader(charset string, input io.Reader) (io.Reader, error) {
        switch strings.ToLower(charset) {
-       case "ascii":
+       case "utf-8", "ascii":
                return input, nil
        default:
                return nil, fmt.Errorf("can't decode XML document using charset %q", charset)