Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the failure of go get downloading package

Shulou Source: shulou.com Published: 2022-06-03 05:07:53 10月04日 Update

This article mainly explains "how to solve the failure of go get download package". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it to study and learn "how to solve the failure of go get download package" together!

Go get download package failure problem

Due to some force majeure reasons, timeout problems often occur when installing packages using the go get command in China. This article describes several common solutions.

Clone from github

Golang has created a mirror library on github, such as https://github.com/golang/net corresponding to https://golang.org/x/net mirror library. To download the golang.org/x/net package, you can use git clone to pull the source code file of the corresponding package after creating the directory of the package locally, as follows:

mkdir -p $GOPATH/src/golang.org/xcd $GOPATH/src/golang.org/xgit clone https://github.com/golang/net.git Use gopm

Gopm can be downloaded from a number of mirror sites at golang. org.

Install gopmgo get -u github.com/gpmgo/gopm Install third-party packages using gopm

Without the-g parameter, the dependency package will be downloaded under the.vendor directory; with the-g parameter, the dependency package can be downloaded to the GOPATH directory.

gopm get -g golang.org/x/net Use goproxy

After version 1.11 of Go, you can set the GOPROXY variable to set the proxy. If you have your own proxy server, you can set this environment variable to your proxy. First open the go module Support:

Running on Mac/Linux:

export GO111MODULE=on

Windows Platform Execution:

SET GO111MODULE=on

2019.6.10 Update: goproxy.cn

Here we take https://goproxy. cn as an example:

On Mac/Linux, you can execute the following command:

export GOPROXY=https://goproxy.cn

For Windows platforms, execute the following command in cmd to set:

SET GOPROXY="https://goproxy.cn"

Or execute in PowerShell:

C:\> $env:GOPROXY = "https://goproxy.cn" Thank you for reading, the above is "how to solve the go get download package failure" content, after the study of this article, I believe everyone on how to solve the go get download package failure This problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Commands directories mirrors problems agents learning content parameters variables platforms force majeure methods reasons that is regular meetings common ideas situations resistance files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB Shulou Tech Info Shulou Information macOS