Home  >  Article  >  Backend Development  >  Detailed explanation of go get command

Detailed explanation of go get command

尚
forward
2019-11-28 15:07:348325browse

Detailed explanation of go get command

go get

Download the package specified by the import path and its dependencies, and then install the named package, that is, execute the go install command. (Recommended: go language tutorial)

Usage: go get [-d] [-f] [-t] [-u] [-fix] [-insecure] [build flags ] [packages]

Tag Name Description
-d Let the command program only perform the download action and not the installation action.
-f is only valid when using the -u flag. This flag will cause the command program to ignore checking the import path of the downloaded code package. This is especially important if the code package you downloaded and installed belongs to a project that you forked from someone else.
-fix Let the command program perform corrective actions first after downloading the code package, and then compile and install it.
-insecure Allows the command program to use an insecure scheme (such as HTTP) to download the specified code package. If the code repository you use (such as the company's internal Gitlab) does not support HTTPS, you can add this tag. Please use it only when you are sure it is safe.
-t Let the command program download and install the dependent code packages in the test source code file in the specified code package at the same time.
-u Let the command use the network to update existing code packages and their dependent packages. By default, this command will only download code packages that do not exist locally from the network and will not update existing code packages.
-v Print out the name of the code package being built
-x Print out Commands used

go install

Use: go install [-i] [build flags] [packages].

is similar to the go build command. The go build command will compile the package and its dependencies, and the generated files will be stored in the current directory. Moreover, go build is only valid for the main package and does not work for other packages. For non-main packages, go install will generate static files and place them in the $GOPATH/pkg directory, with the file extension a. If it is the main package, an executable binary file with the same name as the given package will be generated under $GOPATH/bin.

To summarize: The go get command will download the specified package, compile the downloaded package, and then install it to a specific directory.

The above is the detailed content of Detailed explanation of 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