Skip to content

Commit 95e1ea4

Browse files
author
Bryan C. Mills
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 8fb9fa3 commit 95e1ea4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/cmd/go/internal/get/discovery.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ func charsetReader(charset string, input io.Reader) (io.Reader, error) {
2828

2929
// parseMetaGoImports returns meta imports from the HTML in r.
3030
// Parsing ends at the end of the <head> section or the beginning of the <body>.
31-
func parseMetaGoImports(r io.Reader, mod ModuleMode) (imports []metaImport, err error) {
31+
func parseMetaGoImports(r io.Reader, mod ModuleMode) ([]metaImport, error) {
3232
d := xml.NewDecoder(r)
3333
d.CharsetReader = charsetReader
3434
d.Strict = false
35-
var t xml.Token
35+
var imports []metaImport
3636
for {
37-
t, err = d.RawToken()
37+
t, err := d.RawToken()
3838
if err != nil {
39-
if err == io.EOF || len(imports) > 0 {
40-
err = nil
39+
if err != io.EOF && len(imports) == 0 {
40+
return nil, err
4141
}
4242
break
4343
}

0 commit comments

Comments
 (0)