You are not logged in.

#1 2018-03-06 10:39:53

ozramsay
Member
Registered: 2018-03-06
Posts: 6

Golang: GOPATH is set but does not work

Hi, I have set GOPATH variable:

[oz@admin25 rediscovery]$ go env GOPATH
/home/oz/go

But when I am trying to use go get I receive an error:

[oz@admin25 rediscovery]$ go get github.com/stretchr/testify
package github.com/stretchr/testify: cannot download, /home/oz/go is a GOROOT, not a GOPATH. For more details see: 'go help gopath'
[oz@admin25 rediscovery]$ go version
go version go1.9.1 linux/amd64

[oz@admin25 rediscovery]$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/oz/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build561636698=/tmp/go-build -gno-record-gcc-switches"
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"
[oz@admin25 rediscovery]$ env | grep GO
GOPATH=/home/oz/go

[oz@admin25 rediscovery]$ pacman -Si go
Repository      : extra
Name            : go
Version         : 2:1.9.1-1
Description     : Core compiler tools for the Go programming language
Architecture    : x86_64
URL             : http://golang.org/
Licenses        : BSD
Groups          : None
Provides        : go-pie
Depends On      : None
Optional Deps   : None
Conflicts With  : go-pie
Replaces        : None
Download Size   : 44.99 MiB
Installed Size  : 220.79 MiB
Packager        : Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
Build Date      : Mon 09 Oct 2017 04:48:03 PM +05
Validated By    : MD5 Sum  SHA-256 Sum  Signature

Offline

#2 2018-03-07 14:45:32

eda2z
Member
From: Woodstock, IL
Registered: 2015-04-21
Posts: 71

Re: Golang: GOPATH is set but does not work

Except for a few minor differences (oz is not my login name and I have GOCACHE set) I was able to perform the "go get" from github successfully.  That error usually indicates that you have something installed under GOPATH which go is interpreting as part of the go installation and you are not allowed to have GOPATH and GOROOT pointing to the same directory.  You should check what sub-directories you have under ~/go, probably back them up, and selectively delete them until you can perform the "go get".

Offline

#3 2018-03-07 17:00:31

ozramsay
Member
Registered: 2018-03-06
Posts: 6

Re: Golang: GOPATH is set but does not work

eda2z wrote:

Except for a few minor differences (oz is not my login name and I have GOCACHE set) I was able to perform the "go get" from github successfully.  That error usually indicates that you have something installed under GOPATH which go is interpreting as part of the go installation and you are not allowed to have GOPATH and GOROOT pointing to the same directory.  You should check what sub-directories you have under ~/go, probably back them up, and selectively delete them until you can perform the "go get".

Thank you very much.

Offline

Board footer

Powered by FluxBB