godef icon indicating copy to clipboard operation
godef copied to clipboard

godef needs GOPATH set but this is not needed by Go 1.9 onwards

Open duncanharris opened this issue 7 years ago • 3 comments

I have Go installed to a non-standard path. With Go 1.9 all you need is the go executable on the path and then Go figures everything out from there. However godef is not so clever and wants GOROOT to be set.

The following shows my Go environment with godef not working and then me setting GOROOT to get it working.

$ ls -l `which go`
lrwxrwxrwx 1 root root 29 Sep 12 11:01 /usr/bin/go -> /home/duncan/.go/go1.9/bin/go
$ set | fgrep GO
GOPATH=/home/duncan/.local
$ go version
go version go1.9 linux/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/duncan/.local"
GORACE=""
GOROOT="/home/duncan/.go/go1.9"
GOTOOLDIR="/home/duncan/.go/go1.9/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build177033922=/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"
$ godef -f pkg/data/codebook/codebook.go csv.Reader
parseLocalPackage error: no more package files found
godef: no declaration found for csv.Reader
$ export GOROOT=/home/duncan/.go/go1.9
$ godef -f pkg/data/codebook/codebook.go csv.Reader
/home/duncan/.go/go1.9/src/encoding/csv/reader.go:90:6
$ set | fgrep GO
GOPATH=/home/duncan/.local
GOROOT=/home/duncan/.go/go1.9
$ 

duncanharris avatar Oct 19 '17 20:10 duncanharris

I have the same problem. I am using Go 1.9.1.

yaojingguo avatar Oct 24 '17 08:10 yaojingguo

the same prooblem,did you fand the way?come share

csuzuliangpan avatar Dec 13 '17 17:12 csuzuliangpan

You can try to set GOPATH.

yaojingguo avatar Dec 14 '17 11:12 yaojingguo