Home >Backend Development >Golang >Why Does \'go tool: no such tool \'compile\'\' Appear After Manually Installing Go on Ubuntu?

Why Does \'go tool: no such tool \'compile\'\' Appear After Manually Installing Go on Ubuntu?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-29 06:20:11329browse

Why Does

Troubleshooting "go tool: no such tool "compile"

Encountering the error "go tool: no such tool "compile"" when building a Go project can be perplexing, especially when the environment had been working properly before. This issue often arises on Ubuntu systems after installing Go directly by downloading the tar.gz file instead of using apt-get.

Potential Cause:

Installing godoc using sudo apt-get install golang-doc can potentially conflict with the manually installed Go version, leading to a discrepancy in the GOROOT environment variable.

Solution:

To resolve this issue, explicitly set the GOROOT environment variable to the path of the manually installed Go directory using the following command:

export GOROOT="/usr/local/go"

Additional Information:

  • The go env command displays the current environment variables related to Go.
  • The go version command provides information about the installed version of Go.
  • Manually installing Go by downloading the tar.gz file provides more flexibility and control over the installation, but it also requires additional setup and potential conflict resolution.
  • If exporting GOROOT does not resolve the issue, consider reinstalling Go using apt-get or re-extracting the tar.gz file and ensuring the correct environment variables are set.

The above is the detailed content of Why Does \'go tool: no such tool \'compile\'\' Appear After Manually Installing Go on Ubuntu?. 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