I am a newbie in GOlang and Hyperledger fabric, I was just configuring the environment. But I got a weird error that is given bellow
user1@NTP-145UBUNTU:~$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/lib/go-1.6/bin"
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"
user1@NTP-145UBUNTU:~$ sudo go get -u github.com/hyperledger/fabric-sdk-go
[sudo] password for user1:
package github.com/hyperledger/fabric-sdk-go: cannot download, $GOPATH not set. For more details see: go help gopath
It is saying that my GOPATH env variable is not set. I have configured it and its is showing in evn variable list also. If anyone in here faced this issue please help me. please note : I am using ubuntu 16 LTS
thanks in advance.
You are executing go get
with sudo
. That will cause all your env variables to be lost, as the command gets executed as user root
.
Usually this should not be necessary. $GOPATH is usually set to $HOME/go/
. This is also the default value. You should set $GOPATH to this value. After that you do not have to call go get
with sudo
.
And as pizza lord suggested, you should update your go version.
Remove the existing golang version packaged with ubuntu. Update you golang version to 1.9 or latest .
$ sudo apt-get remove golang-go
$ sudo apt-get remove --auto-remove golang-go
$ sudo add-apt-repository ppa:gophers/archive
$ sudo apt-get update
$ sudo apt-get install golang-1.10-go
Update ~/.bash_profile with golang variables
export PATH=$PATH:"/usr/lib/go-1.10/bin"
export GOPATH=$HOME/go
There are 2 possible mistakes
$GOPATH
correctly.try this.
mkdir ~/go-workspace
and in your .bashrc
file, append this
export GOPATH=~/go-workspace
go get
with sudo
.try :
go get -u github.com/hyperledger/fabric-sdk-go
if you get permission denied error, try
sudo chown user1 $(echo $GOPATH)