Skip to content

cmd/doc: go doc -http fails with undownloaded modules #73833

Closed
@matloob

Description

@matloob

'go run' checks to see if the pkg@version being run is deprecated by fetching the latest version of the module. If it can't fetch the latest version, it produces a fatal error and stops.

We probably shouldn't do that and instead notify the user that we couldn't fetch deprecations, but that's something we'd need to do in 1.26.

Our solution to allow 'go doc' to run the pkgsite code, when there was no network, was to do a go mod download of pkgsite, and then 'go run' the code with GOPROXY=off. Then if there was no network but pkgsite was already downloaded, the download would succeed without doing anything, and the go run could skip the deprecation check with no network (we also added support to skip the deprecation check with no network). If there was network, but pkgsite wasn't downloaded, the download would download pkgsite with the usual goproxy setting, and then run pkgsite with goproxy=off, finding the pkgsite code in the module cache.

But there's a problem: if all the modules needed by pkgsite to show documentation aren't downloaded, the go command it invokes will fail due to GOPROXY=off. We should fix that.

Instead of the two step go mod download and then GOPROXY=off go run pkgsite we should instead just run pkgsite with the local download cache prepended to the GOPROXY. That will silence the deprecation checks with no network if we've already downloaded pkgsite because it will find a latest version in the download cache, and it will also allow the go command to find modules that haven't been downloaded by falling back to the GOPROXY entries set by the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions