From: Bryan C. Mills Date: Mon, 5 Aug 2019 18:32:46 +0000 (-0400) Subject: cmd/go/internal/get: make the implementation of charsetReader match its comment X-Git-Tag: go1.14beta1~1133 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8fb9fa36f5b7cf161d0694fdb418af7c83b946d5;p=gostls13.git cmd/go/internal/get: make the implementation of charsetReader match its comment 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 TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- diff --git a/src/cmd/go/internal/get/discovery.go b/src/cmd/go/internal/get/discovery.go index 6ba5c091e3..aa2a24d12f 100644 --- a/src/cmd/go/internal/get/discovery.go +++ b/src/cmd/go/internal/get/discovery.go @@ -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)