Skip to content

Non-empty stderr for go list is not an error in itself#1981

Merged
sdghchj merged 1 commit into
swaggo:masterfrom
atercattus:go-mod-stderr
Mar 21, 2025
Merged

Non-empty stderr for go list is not an error in itself#1981
sdghchj merged 1 commit into
swaggo:masterfrom
atercattus:go-mod-stderr

Conversation

@atercattus

Copy link
Copy Markdown
Contributor

Describe the PR
The current implementation of getting a list of packages (listPackages) assumes that a non-empty stderr in the output of go list is an error, regardless of the result of the call, which is not true. Here is an example of a non-empty stderr:

go: downloading github.com/go-sql-driver/mysql v1.8.1
go: downloading github.com/go-errors/errors v1.0.1
go: downloading github.com/go-playground/validator/v10 v10.22.1
...
go: downloading go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0
go: downloading github.com/felixge/httpsnoop v1.0.4

There is no information on errors. This is a legitimate output of additional information.

As a result, we get a non-zero status code without any reason.

Let's rely on the error return, and only add the contents of stderr along with it (preferably removing all lines with go: downloading).

@sdghchj sdghchj merged commit 257c97c into swaggo:master Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants