ankush981
(Ankush Thakur)
October 25, 2017, 12:42pm
1
I have a weird problem in my system where Go can’t seem to find the “goimports” package even when I’m asking it to install the “goimports” package! Here’s how it goes:
$ go get -u golang.org/x/tools/cmd/goimports
package golang.org/x/tools/cmd/goimports: cannot find package "golang.org/x/tools/cmd/goimports" in any of:
/usr/local/go/src/golang.org/x/tools/cmd/goimports (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/cmd/goimports (from $GOPATH)
This actually happened when trying out the Buffalo web framework, but I will ask separate questions if needed. Here’s my go env
:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ankush/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build102401191=/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"
I’m going around in circles here. Please help!
luk4z7
(Lucas Alves)
October 25, 2017, 1:08pm
2
Exist an problem with your GOPATH, in your GOPATH “/home/ankush/go” have a folder with name “src” ?
ankush981
(Ankush Thakur)
October 25, 2017, 1:17pm
3
Yup.
src$ pwd
/home/ankush/go/src
src$ ls
buffalo-projects github.com golang-book golang.org gopkg.in sourcegraph.com
luk4z7
(Lucas Alves)
October 25, 2017, 1:20pm
4
Try this:
cd /home/ankush/go/
export GOPATH=$( pwd )
export PATH=$PATH:$GOPATH/bin
go get -u golang.org/x/tools/cmd/goimports
ankush981
(Ankush Thakur)
October 25, 2017, 3:46pm
5
I did that but it didn’t help. I don’t think it’s the problem with GOPATH. Here’s my go env
output (from another terminal session):
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ankush/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build884564472=/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"
ankush981
(Ankush Thakur)
October 25, 2017, 5:33pm
7
Here’s my output:
$ go get -u golang.org/x/tools/...
package golang.org/x/tools/go/buildutil: cannot find package "golang.org/x/tools/go/buildutil" in any of:
/usr/local/go/src/golang.org/x/tools/go/buildutil (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/buildutil (from $GOPATH)
package golang.org/x/tools/go/callgraph: cannot find package "golang.org/x/tools/go/callgraph" in any of:
/usr/local/go/src/golang.org/x/tools/go/callgraph (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/callgraph (from $GOPATH)
package golang.org/x/tools/go/callgraph/cha: cannot find package "golang.org/x/tools/go/callgraph/cha" in any of:
/usr/local/go/src/golang.org/x/tools/go/callgraph/cha (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/callgraph/cha (from $GOPATH)
package golang.org/x/tools/go/callgraph/rta: cannot find package "golang.org/x/tools/go/callgraph/rta" in any of:
/usr/local/go/src/golang.org/x/tools/go/callgraph/rta (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/callgraph/rta (from $GOPATH)
package golang.org/x/tools/go/callgraph/static: cannot find package "golang.org/x/tools/go/callgraph/static" in any of:
/usr/local/go/src/golang.org/x/tools/go/callgraph/static (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/callgraph/static (from $GOPATH)
package golang.org/x/tools/go/loader: cannot find package "golang.org/x/tools/go/loader" in any of:
/usr/local/go/src/golang.org/x/tools/go/loader (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/loader (from $GOPATH)
package golang.org/x/tools/go/pointer: cannot find package "golang.org/x/tools/go/pointer" in any of:
/usr/local/go/src/golang.org/x/tools/go/pointer (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/pointer (from $GOPATH)
package golang.org/x/tools/go/ssa: cannot find package "golang.org/x/tools/go/ssa" in any of:
/usr/local/go/src/golang.org/x/tools/go/ssa (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/ssa (from $GOPATH)
package golang.org/x/tools/go/ssa/ssautil: cannot find package "golang.org/x/tools/go/ssa/ssautil" in any of:
/usr/local/go/src/golang.org/x/tools/go/ssa/ssautil (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/go/ssa/ssautil (from $GOPATH)
package golang.org/x/tools/godoc/analysis: cannot find package "golang.org/x/tools/godoc/analysis" in any of:
/usr/local/go/src/golang.org/x/tools/godoc/analysis (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/godoc/analysis (from $GOPATH)
package golang.org/x/tools/godoc/util: cannot find package "golang.org/x/tools/godoc/util" in any of:
/usr/local/go/src/golang.org/x/tools/godoc/util (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/godoc/util (from $GOPATH)
package golang.org/x/tools/godoc/vfs: cannot find package "golang.org/x/tools/godoc/vfs" in any of:
/usr/local/go/src/golang.org/x/tools/godoc/vfs (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/godoc/vfs (from $GOPATH)
Looks like there were a lot of errors. Also, the original problem remains unresolved.
calmh
(Jakob Borg)
October 25, 2017, 5:46pm
8
Is your GOPATH or any part of it symlinked to somewhere else?
luk4z7
(Lucas Alves)
October 25, 2017, 5:50pm
9
The installation is correct, I installed in my environment, try install another package,
go get github.com/getsentry/raven-go
ankush981
(Ankush Thakur)
October 25, 2017, 6:06pm
10
Nope. /home/ankush/go
is a regular directory.
ankush981
(Ankush Thakur)
October 25, 2017, 6:08pm
11
Yes, I was able to install it. Here’s what the directory looks like:
$ ls /home/ankush/go/src/github.com/getsentry/raven-go/
client.go example/ .gitignore LICENSE .travis.yml
client_test.go examples_test.go .gitmodules README.md writer.go
Dockerfile.test exception.go http.go runtests.sh
.dockerignore exception_test.go http_test.go stacktrace.go
docs/ .git/ interfaces.go stacktrace_test.go
luk4z7
(Lucas Alves)
October 25, 2017, 6:10pm
12
ankush981
(Ankush Thakur)
October 26, 2017, 3:54am
13
Same error again.
$ go get golang.org/x/tools/cmd/goimports
package golang.org/x/tools/cmd/goimports: cannot find package "golang.org/x/tools/cmd/goimports" in any of:
/usr/local/go/src/golang.org/x/tools/cmd/goimports (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/cmd/goimports (from $GOPATH)
ankush981
(Ankush Thakur)
October 26, 2017, 4:50am
15
You mean this?
$ ls -l /home/ankush/go/src
total 24
drwxrwxr-x 3 ankush ankush 4096 Oct 25 23:05 buffalo-projects
drwxrwxr-x 41 ankush ankush 4096 Oct 25 23:36 github.com
drwxrwxr-x 12 ankush ankush 4096 Jul 8 22:07 golang-book
drwxrwxr-x 3 ankush ankush 4096 Jul 8 18:07 golang.org
drwxrwxr-x 4 ankush ankush 4096 Oct 25 10:56 gopkg.in
drwxrwxr-x 3 ankush ankush 4096 Jul 8 19:00 sourcegraph.com
bins
(Sebastien Binet)
October 26, 2017, 7:09am
17
and what would be the output of:
$> go get -u -v golang.org/x/tools/cmd/goimports
?
ankush981
(Ankush Thakur)
October 26, 2017, 7:16am
18
Here you go:
$ go get -u -v golang.org/x/tools/cmd/goimports
Fetching https://golang.org/x/tools/cmd/goimports?go-get=1
Parsing meta tags from https://golang.org/x/tools/cmd/goimports?go-get=1 (status code 200)
get "golang.org/x/tools/cmd/goimports": found meta tag get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/cmd/goimports?go-get=1
get "golang.org/x/tools/cmd/goimports": verifying non-authoritative meta tag
Fetching https://golang.org/x/tools?go-get=1
Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200)
golang.org/x/tools (download)
package golang.org/x/tools/cmd/goimports: cannot find package "golang.org/x/tools/cmd/goimports" in any of:
/usr/local/go/src/golang.org/x/tools/cmd/goimports (from $GOROOT)
/home/ankush/go/src/golang.org/x/tools/cmd/goimports (from $GOPATH)
bins
(Sebastien Binet)
October 26, 2017, 7:23am
19
hum…
could you try removing by hand that directory?
$> rm -rf /home/ankush/go/src/golang.org/x/tools
and then re-go-get the package ?
2 Likes
ankush981
(Ankush Thakur)
October 26, 2017, 7:27am
20
Wooohooo! That worked!
Now, the only question is, why?
1 Like
bins
(Sebastien Binet)
October 26, 2017, 7:31am
21
it’s left as an exercize for the reader
(I am guessing the tools
repo hadn’t been really checked out with a proper go get
nor a git clone
(but perhaps just mkdir tools
) preventing go get -u
to properly update it later on.)
ankush981
(Ankush Thakur)
October 26, 2017, 7:33am
22
LOL!
Hmmm, that kinda makes sense. Thanks for all the help!
system
(system)
Closed
January 24, 2018, 7:33am
23
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.