mirror of
https://github.com/golang/go
synced 2024-11-27 05:11:22 -07:00
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: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
8fb9fa36f5
commit
95e1ea4598
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user