Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix go mod download output expectation for errors #1442

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions language/go/update_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ definitely.doesnotexist/ever v0.1.0/go.mod h1:HI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqw
return []byte(`{
"Path": "definitely.doesnotexist/ever",
"Version": "0.1.0",
"Error": {
"Err": "Did not exist"
}
"Error": "Did not exist"
}`), fmt.Errorf("failed to download")
},
}, {
Expand Down
10 changes: 3 additions & 7 deletions language/go/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ type moduleError struct {
Err string
}

type downloadError struct {
Err string
}

// moduleFromDownload is an abstraction to preserve the output of `go mod download`.
// The output schema is documented at https://go.dev/ref/mod#go-mod-download
type moduleFromDownload struct {
Expand All @@ -74,7 +70,7 @@ type moduleFromDownload struct {
Replace *struct {
Path, Version string
}
Error *downloadError
Error string
}

// extractModules lists all modules except for the main module,
Expand Down Expand Up @@ -136,8 +132,8 @@ func fillMissingSums(pathToModule map[string]*moduleFromList) (map[string]*modul
err = fmt.Errorf("%w\nError parsing module for more error information: %v", err, decodeErr)
break
}
if dl.Error != nil {
err = fmt.Errorf("%w\nError downloading %v: %v", err, dl.Path, dl.Error.Err)
if dl.Error != "" {
err = fmt.Errorf("%w\nError downloading %v: %v", err, dl.Path, dl.Error)
}
}
err = fmt.Errorf("error from go mod download: %w", err)
Expand Down