golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.94k stars 17.53k forks source link

proposal: x/dl: add GODLPROXY= for support to specify the download site of the go installation package #61296

Open notobject opened 1 year ago

notobject commented 1 year ago

add GODLPROXY= to specify the download site of the go installation package, and use the current address (https://dl.google.com/go/) as the default value instead of the only value

this proposal is about multi-version. see Managing Go installations I have installed 1.16.2 now, and I also want to experience 1.20.5, so I found pkg golang.org/dl, But when I try to execute go1.20.5 download, its default behavior is to download the compressed file required from https://dl.google.com/go, and this address cannot be configured. I can't connect to this address in my development environment, but there are mirror sites that can replace it, so I propose to add an environment variable to allow the configuration of the download address.

file dl/internal/version/version.go

// versionArchiveURL returns the zip or tar.gz URL of the given Go version.
func versionArchiveURL(version string) string {
        goos := getOS()

        ext := ".tar.gz"
        if goos == "windows" {
                ext = ".zip"
        }
        arch := runtime.GOARCH
        if goos == "linux" && runtime.GOARCH == "arm" {
                arch = "armv6l"
        }
        downloadURL := "https://dl.google.com/go/"

         // TODO use GODLPROXY if not empty 

        return downloadURL + version + "." + goos + "-" + arch + ext
}
dmitshur commented 1 year ago

Have you considered the existing proxy support in the net/http package via the HTTPS_PROXY and similar environment variables?

seankhliao commented 1 year ago

I thought the original discussion in #55092 proposed using the module proxy directly?

heschi commented 1 year ago

This is about the golang.org/x/dl commands, e.g. go1.20.6, not about #55092. But I think it's basically obsoleted by the forward compatibility stuff launching in 1.21.

notobject commented 1 year ago

This is about the golang.org/x/dl commands, e.g. go1.20.6, not about #55092. But I think it's basically obsoleted by the forward compatibility stuff launching in 1.21.

Yes, this proposal is about multi-version. see Managing Go installations I have installed 1.16.2 now, and I also want to experience 1.20.5, so I found pkg golang.org/dl, But when I try to execute go1.20.5 download, its default behavior is to download the compressed file required from https://dl.google.com/go, and this address cannot be configured. I can't connect to this address in my development environment, but there are mirror sites that can replace it, so I propose to add an environment variable to allow the configuration of the download address.

zigo101 commented 1 year ago

For each toolchain release, we can create a Go module project by using the Go embedding feature to embed the whole toolchain release, so that the dl command can be re-written to call go get to download the toolchain release.