Home >Backend Development >Golang >Some instructions on downloading expansion packages using the go get command

Some instructions on downloading expansion packages using the go get command

尚
forward
2020-02-25 17:03:583992browse

The go get command can remotely pull or update code packages and their dependent packages with the help of code management tools, and automatically complete compilation and installation. The following section will introduce some knowledge about downloading expansion packs using the go get command from the go Getting Started Tutorial column.

Some instructions on downloading expansion packages using the go get command1. The storage path of go get

The source code downloaded by go get is saved in $GOPATH/src. If it is not set, it will be included in $HOME/ by default. Go/src directory.

The downloaded package path maintains the same structure as the local path. For example, use the following command to download the specified package from github:

$ go get -u -v github.com/sqs/goreturns
$

The downloaded source code will be saved in $GOPATH/src/github. com/sqs/goreturns.

We can also manually download the package to the corresponding path, and then execute the go get download command, such as:

$ git clone https://github.com/sqs/goreturns $GOPATH/src/github.com/sqs/
$ go get -u -v github.com/sqs/goreturns
$

For tool packages that need to be compiled into binaries, you can use the go install command Compile and install the package. Binary files are stored in the $GOPATH/bin directory by default.

Note: The github package needs to be downloaded using the git clone command. It cannot be downloaded and decompressed directly in the browser, otherwise an error will be reported error: is not using a known version control system

2. github mirror

github warehouse https://github.com/golang is the official mirror warehouse of golang. All packages can be downloaded from the mirror repository. For example, to download the golang.org/x/tools tool package, you can download it from github.com/golang/tools.

$ git clone https://github.com/golang/tools $HOME/go/src/golang.org/x/
$

It is recommended to download the package to the $GOPATH/src/golang.org/x/ directory.

For more go language knowledge, please pay attention to the go language tutorial column on the php Chinese website.

The above is the detailed content of Some instructions on downloading expansion packages using the go get command. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete