I've placed my path variables as follows:
export GOROOT=/usr/local/go
export GOPATH=$HOME/Professional/Sch/Fabric/go
export GOBIN=/usr/local/go/bin
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
I've placed these lines in both ~/.profile and ~/.bashrc and sourced them both (not sure which of them is taking effect).
my go env output:
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCACHE="/home/deepak/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/deepak/Professional/Sch/Fabric/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build653871525=/tmp/go-build -gno-record-gcc-switches"
I've placed the following code in $HOME/Professional/Sch/Fabric/go/hellp.go:
package main
import "fmt"
func main() {
fmt.Printf("Hello, World!\n")
}
but each time i do go install hellp.go
, I get:
go install command-line-arguments: open /usr/local/go/bin/hellp: permission denied
which is strange because go version
returns a go version go1.10.4 linux/amd64
, and I'm not sure why its trying to reference /usr/local/go/bin/hellp
as there is no 'hellp' file there, its a sample file I created at $HOME/Professional/Sch/Fabric/go/
.
I'm not sure which directory permission is missing, but I've tried:
201 sudo chmod -R 777 ~/Professional/Sch/Fabric
202 go install hellp.go
203 sudo chmod -R 777 ~/Professional/Sch/Fabric/go/hellp.go
204 go install hellp.go
205 sudo chmod -R 777 ~
My uname -a output:
Linux instance-1 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 GNU/Linux
I'm trying to install HyperLedger Fabric for which Go is a prerequisite, and clearly go version
output shows its successfully installed, however, I'm not sure where or how it needs to be configured to test and use it.
Your
GOBIN
setting is tellinggo install
to try to install compiled binaries into a system-global directory you don't have permission to write to. Try unsetting that variable; things should default to being installed in$GOPATH/bin
.Also remember that
go install
takes a package name, not a filename, as its parameter. I'm not clear you cango install
something in$GOPATH/src
directly, but you can move it into a subdirectory