cannot find package "_/root/pagespeed_exporter", cannot find package "_/root/pagespeed_exporter/collector"
Closed this issue · 4 comments
Hello,
I am trying to build the exporter for our usage. I have installed golang on CentOS 6 (the OS the server is running):
Name : golang
Arch : x86_64
Version : 1.11.5
Release : 1.el6
Size : 6.9 M
Repo : installed
From repo : epel
Summary : The Go Programming Language
URL : http://golang.org/
License : BSD and Public Domain
Description : The Go Programming Language.
I cloned this git repo so it is latest code. When I run make in the pagespeed_exporter folder, it errors with:
formatting code
can't load package: package /root/pagespeed_exporter: cannot find package "/root/pagespeed_exporter" in any of:
/usr/lib/golang/src//root/pagespeed_exporter (from $GOROOT)
/root/go/src//root/pagespeed_exporter (from $GOPATH)
can't load package: package /root/pagespeed_exporter/collector: cannot find package "/root/pagespeed_exporter/collector" in any of:
/usr/lib/golang/src//root/pagespeed_exporter/collector (from $GOROOT)
/root/go/src//root/pagespeed_exporter/collector (from $GOPATH)
make: *** [format] Error 1
What is the resolution to get make to find these packages? Should they not be part of this source code?
Note that $GOROOT and $GOPATH are both unset. Are they supposed to be set to something? Perhaps this should be handled by the Makefile?
@conseev well, that's the standard go installation path! The project should be checked out into (regarding your traces) to /root/go/src/foomo/pagespeed_exporter.
The makefile assumes that you have checked it out in the gopath directory. (like if you did a go get github.com/foomo/pagespeed_exporter)
You can also use the docker file to build the dockerized image by doing a docker build . (in the checked out folder)
Thanks, doing "go get github.com/foomo/pagespeed_exporter" did generate a working build path at ~/go/src/github.com/foomo/pagespeed_exporter. I also had to, before running make for the exporter, do "go get github.com/golang/dep" and build that and put dep in /usr/bin/local/.
After that, the exporter built even though the makefile still failed with:
running tests
? github.com/foomo/pagespeed_exporter [no test files]
fork/exec /tmp/go-build069946641/b129/collector.test: permission denied
FAIL github.com/foomo/pagespeed_exporter/collector 0.000s
make: *** [test] Error 1
That is likely our fault since we mount tmp with noexec. :)
No probs, yeah, go should have permissions to /tmp/ for test running