Addem Addem - 5 months ago 20
Linux Question

Installing Go on Linux, testing fails

I'm following the instructions at this page to try to install Go. I have downloaded the file and extracted it without issue. I opened the

profile
file and went to the end of the file where I inserted the indicated
export
line. I created all the indicated directories to make a tree structure, ran the
export
command from the bash shell, created the
hello.go
file as instructed.

Yet when I run
go install github.com/user/hello
I get the error

can't load package: package github.com/user/hello: cannot find package "github.com/user/hello" in any of:
/usr/local/go/src/github.com/user/hello (from $GOROOT)
/work/src/github.com/user/hello (from $GOPATH)

Answer

Try this:

export GOPATH=$HOME/work
cd $GOPATH
mkdir src
mv github.com src/

Go expects your source code to be in a directory called src.

Comments