Skip to content

Commit

Permalink
cmd/go/internal/get: propagate parse errors in parseMetaGoImports
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Bryan C. Mills committed Sep 11, 2019
1 parent 8fb9fa3 commit 95e1ea4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cmd/go/internal/get/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ func charsetReader(charset string, input io.Reader) (io.Reader, error) {

// parseMetaGoImports returns meta imports from the HTML in r.
// 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.CharsetReader = charsetReader
d.Strict = false
var t xml.Token
var imports []metaImport
for {
t, err = d.RawToken()
t, err := d.RawToken()
if err != nil {
if err == io.EOF || len(imports) > 0 {
err = nil
if err != io.EOF && len(imports) == 0 {
return nil, err
}
break
}
Expand Down

0 comments on commit 95e1ea4

Please sign in to comment.