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

cmd/go/internal/modcmd: download with -json flag doesn't print JSON objects to stdout for some module download errors #69510

Open
dmitshur opened this issue Sep 17, 2024 · 1 comment
Assignees
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Sep 17, 2024

Go version

go version go1.23.1 darwin/arm64

Output of go env -changed in your module/workspace


GOPROXY='http://127.0.0.1'

What did you do?

https://pkg.go.dev/cmd/go#hdr-Download_modules_to_local_cache says:

The -json flag causes download to print a sequence of JSON objects to standard output, describing each downloaded module (or failure), corresponding to this Go struct: type Module struct { ... }

It seems that doesn't always happen for some networking errors observed in the Go build system (build 8736907273916323825 being one example). Consider a minimal set of steps which seems to reproduce the problem:

$ export GOPROXY=http://127.0.0.1  # simulate an error downloading modules
$ cd $(mktemp -d)
$ printf 'module test\nrequire example.com v0.0.0\n' > go.mod
$ go mod download -json

What did you see happen?

No JSON is printed to stdout:

$ go mod download -json 2>/dev/null
$

What did you expect to see?

JSON is printed to stdout, describing the error:

$ go mod download -json 2>/dev/null
{
	"Path": "example.com",
	"Version": "v0.0.0",
	"Error": "Get \"http://127.0.0.1/example.com/@v/v0.0.0.mod\": dial tcp 127.0.0.1:80: connect: connection refused"
}
$

CC @matloob, @samthanawalla.

@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Sep 17, 2024
@dmitshur dmitshur added this to the Backlog milestone Sep 17, 2024
@matloob matloob self-assigned this Sep 24, 2024
@matloob matloob modified the milestones: Backlog, Go1.24 Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants