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