This is somewhat a follow-up to my last question: golang: installing packages in a local directory
I have GOPATH
set to $HOME/prog/go/gopath
and this path exists with three directories:
~/prog/go/gopath$ ls
bin pkg src
Now I try to install a module to access the redis database which asks me to run
go install
inside the source directory. But the command go install
gives me
~/prog/go/gopath/src/redis (go1)$ go install
go install flag: open /usr/local/go/pkg/darwin_amd64/flag.a: permission denied
~/prog/go/gopath/src/redis (go1)$ echo $GOPATH
<myhomedir>/prog/go/gopath
(where <myhomedir>
is a valid path)
Question 1: why does go install
not take $GOPATH
into account?
Question 2: how to convince go install
to use $GOPATH
?
Not sure how you setup go but it's possible that it needs to build packages from std library but can't due to permissions. You can try
cd /usr/local/go/src
sudo ./all.bash
This should build the std library and run tests to make sure everything is ok.
Make sure you have proper permissions to read and execute from $GOROOT as necessary. Personally I just download the archive from golang.org and keep it under ~/local/go and set GOROOT appropriately.