Home  >  Article  >  Backend Development  >  How to install go language related tools

How to install go language related tools

王林
王林Original
2021-02-04 11:24:562260browse

How to install go language related tools: 1. Download the go language tool package on the github platform; 2. Install the tool package by executing the [go install github.com/xxx] command.

How to install go language related tools

The operating environment of this article: windows10 system, Go 1.11.2, thinkpad t480 computer.

The go tool package can be installed through the following four paths:

github.com/
golang.org/
gopkg.in/
honnet.co/

For example, we can download the installation package through go get github.com/xxx

After downloading, through go install github.com/xxx to install the package

The installation package will be downloaded to the $GOPATH/src file

The executable file after installation is in the $GOPATH/bin file

Common errors:

When we execute go get golang.org/x/tools/cmd/goimports, an error will be reported

package golang.org/x/tools/cmd/goimports: unrecognized import path "golang.org/x/tools/cmd/goimports"

This problem will appear in higher versions of golang. The general solution is

# 创建文件夹
mkdir$GOPATH/src/golang.org/x/
# 进入文件夹
cd$GOPATH/src/golang.org/x/
# 下载源码
git clone https://github.com/golang/tools.git
# 安装
go install golang.org/x/tools/cmd/goimports

Similarly, other packages in the golang.org/x/ path can be solved

Related recommendations:golang tutorial

The above is the detailed content of How to install go language related tools. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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