How to install go language related tools

王林
Release: 2023-02-14 14:28:47
Original
2320 people have browsed it

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

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

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

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!

Related labels:
source:php.cn
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