Backend Development 6 min read

How to Resolve golang.org/x Package Download Failures with Proxies and Go Modules

This guide explains why Go commands often cannot download golang.org/x packages, and provides step‑by‑step solutions including setting HTTP/HTTPS proxies, manually cloning mirror repositories, using go.mod replace directives, and configuring the GOPROXY environment variable to ensure reliable dependency retrieval.

Raymond Ops
Raymond Ops
Raymond Ops
How to Resolve golang.org/x Package Download Failures with Proxies and Go Modules

Problem Description

When using

go get

,

go install

, or

go mod

, packages under

golang.org/x/...

frequently fail to download, interrupting development work.

<code>$ go get -u golang.org/x/sys</code>

The command fails, as shown in the screenshot.

Download failure screenshot
Download failure screenshot

Set Proxy

If you have a proxy server, set the environment variables

http_proxy

and

https_proxy

to point to it.

<code>export http_proxy=http://proxyAddress:port
export https_proxy=http://proxyAddress:port</code>

Example with proxy

192.168.21.1:1080

:

<code>export http_proxy=http://192.168.21.1:1080
export https_proxy=http://192.168.21.1:1080</code>

After setting the proxy, the

go get

command succeeds.

<code>$ go get -u golang.org/x/sys</code>

Manual Download

If no proxy is available, you can manually clone a mirror repository from GitHub (e.g.,

zieckey/golang.org

) into

$GOPATH/src/golang.org/x

.

<code>mkdir $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone [email protected]:golang/text.git</code>

Note: this method cannot specify versions because most mirrors lack tags.

Use go mod replace

Since Go 1.11, modules are supported. Enable modules with

export GO111MODULE=on

and add a

replace

directive in

go.mod

to map the blocked package to a reachable repository.

<code>module example.com/demo

require (
    golang.org/x/text v0.3.0
)

replace (
    golang.org/x/text => github.com/golang/text v0.3.0
)</code>

Use GOPROXY

Go 1.11 also introduces the

GOPROXY

environment variable. Setting it to a proxy such as

https://goproxy.io

allows downloading blocked packages without additional configuration.

<code>export GO111MODULE=on
export GOPROXY=https://goproxy.io</code>

On Windows PowerShell:

<code>$env:GOPROXY = "https://goproxy.io"</code>

After setting, the command succeeds and the package is stored under

$GOPATH/pkg/mod/golang.org/x/

.

Successful download screenshot
Successful download screenshot
Package location in GOPATH
Package location in GOPATH
Proxygolangdependency managementgo modulesGOPROXY
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.