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.
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!