diff options
Diffstat (limited to 'src/cmd/go/internal/modfetch/proxy.go')
-rw-r--r-- | src/cmd/go/internal/modfetch/proxy.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modfetch/proxy.go b/src/cmd/go/internal/modfetch/proxy.go index 60ed2a3796..3d4d2becf4 100644 --- a/src/cmd/go/internal/modfetch/proxy.go +++ b/src/cmd/go/internal/modfetch/proxy.go @@ -87,6 +87,14 @@ cached module versions with GOPROXY=https://example.com/proxy. var proxyURL = os.Getenv("GOPROXY") +// SetProxy sets the proxy to use when fetching modules. +// It accepts the same syntax as the GOPROXY environment variable, +// which also provides its default configuration. +// SetProxy must not be called after the first module fetch has begun. +func SetProxy(url string) { + proxyURL = url +} + func lookupProxy(path string) (Repo, error) { if strings.Contains(proxyURL, ",") { return nil, fmt.Errorf("invalid $GOPROXY setting: cannot have comma") |