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

Release: 2020-02-25 17:03:58
forward
3997 people have browsed it

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
$
Copy after login

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
$
Copy after login

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/
$
Copy after login

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!

Related labels:
go
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template