12

I'm trying follow these instructions to install Drive but I can't get Go to work properly.

I keep getting the error:

go tool: no such tool "6g"

When I try to use go get [url]. I also get this error when trying to run a hello world script (to check that Go had installed correctly).

I've tried installing the individual programs recommended in this post (golang-go.tools gccgo-go) regarding fixing this error but the problem persists.

How can I get the 6g tool?

Here are the results of go env:

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GORACE=""
GOROOT="/usr/share/go"
GOTOOLDIR="/usr/share/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"
4
  • did you set GOPATH and GOROOT?
    – Rinzwind
    Mar 7, 2015 at 20:08
  • Yes, first I was getting an error regarding the GOPATH. I used this SO question to find the solution which then brought me to this next error that I can't fix.
    – Bprodz
    Mar 7, 2015 at 20:18
  • Do you need the latest version of Go? It's far easier to install Go from the archive - sudo apt-get install golang. Mar 7, 2015 at 20:36
  • @NathanOsman I don't think so, I just need to be able to compile a program that was written in Go (last September). I ran sudo apt-get install golang but it returned 0 to upgrade, newly install, 62 not to upgrade and I'm still unable to use go get and go run. Do I need to force apt-get to overwrite my current version of Go?
    – Bprodz
    Mar 7, 2015 at 20:44

2 Answers 2

12

The problem is your GOROOT. It should be set to /usr/lib/go (not /usr/share/go).

export GOROOT=/usr/lib/go
2

Installation

  1. Update.

    sudo apt-get update 
    
  2. Install Go language.

    sudo apt-get install golang
    
  3. Set GOPATH to your home folder. After this action, you can use command echo $GOPATH to check the go path location.

    export GOPATH=$HOME/gopath
    
  4. For the GOPATH, it is not required to define it. But you can still define it.

    # Get the go installation root path.
    go env GOROOT
    
    # Set the result of `go env GOROOT` to system variable GOROOT.
    # In this example, the result of `go env GOROOT` is `/usr/lib/go-1.6`
    export GOROOT=/usr/lib/go-1.6
    

Checking Go Environment Variables

  1. Use command go env and you will get:

    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH="/home/casper/gopath"
    GORACE=""
    GOROOT="/usr/lib/go-1.6"
    GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_amd64"
    GO15VENDOREXPERIMENT="1"
    CC="gcc"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
    CXX="g++"
    CGO_ENABLED="1"
    
  2. Now you can see that:

    a. GOPATH is in /home/casper/gopath.

    b. GOROOT is in /usr/lib/go-1.6.

References

1
  • golang package is officially in repository, why should I add a PPA, where these PPAs are known for issues?
    – Anwar
    Aug 13, 2016 at 8:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .