Commit 95e1ea45 authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go/internal/get: propagate parse errors in parseMetaGoImports

The signature of parseMetaGoImports implies that it can return an error,
but it has not done so since CL 119675. Restore the missing error check,
and remove the named return-values to avoid reintroducing this bug in the
future.

Updates #30748
Updates #21291

Change-Id: Iab19ade5b1c23c282f3c385a55ed277465526515
Reviewed-on: https://go-review.googlesource.com/c/go/+/189778
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
parent 8fb9fa36
...@@ -28,16 +28,16 @@ func charsetReader(charset string, input io.Reader) (io.Reader, error) { ...@@ -28,16 +28,16 @@ func charsetReader(charset string, input io.Reader) (io.Reader, error) {
// parseMetaGoImports returns meta imports from the HTML in r. // parseMetaGoImports returns meta imports from the HTML in r.
// Parsing ends at the end of the <head> section or the beginning of the <body>. // Parsing ends at the end of the <head> section or the beginning of the <body>.
func parseMetaGoImports(r io.Reader, mod ModuleMode) (imports []metaImport, err error) { func parseMetaGoImports(r io.Reader, mod ModuleMode) ([]metaImport, error) {
d := xml.NewDecoder(r) d := xml.NewDecoder(r)
d.CharsetReader = charsetReader d.CharsetReader = charsetReader
d.Strict = false d.Strict = false
var t xml.Token var imports []metaImport
for { for {
t, err = d.RawToken() t, err := d.RawToken()
if err != nil { if err != nil {
if err == io.EOF || len(imports) > 0 { if err != io.EOF && len(imports) == 0 {
err = nil return nil, err
} }
break break
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment