Home > Backend Development > Golang > Why Does `go tool: no such tool \'compile\'` Occur After Installing `golang-doc`?

Why Does `go tool: no such tool \'compile\'` Occur After Installing `golang-doc`?

DDD
Release: 2024-12-09 03:31:11
Original
399 people have browsed it

Why Does `go tool: no such tool 'compile'` Occur After Installing `golang-doc`?

No Such Tool "Compile" Error in Go

When attempting to build a Go project after installing godoc using sudo apt-get install golang-doc, users may encounter an error stating, "go tool: no such tool 'compile.'" This issue can arise when the Go environment path is not correctly set.

The go env output provided shows that the GOROOT environment variable is set to /usr/local/go. However, the GOTOOLDIR variable, which specifies the directory containing the Go tools, is set to /usr/local/go/pkg/tool/linux_amd64. This indicates that the Go tools, including the compiler, may not be accessible from the correct path.

To resolve this issue, try the following:

export GOROOT=/usr/local/go
Copy after login

This command will set the GOROOT environment variable to the correct path for the Go installation. After running this command, try building the project again with go build. If this does not resolve the issue, you may need to consult the Go documentation or seek further assistance from the Go community.

The above is the detailed content of Why Does `go tool: no such tool 'compile'` Occur After Installing `golang-doc`?. For more information, please follow other related articles on the PHP Chinese website!

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