sapcc / mosquitto-exporter

Prometheus metrics exporter for the Mosquitto message broker
Apache License 2.0
130 stars 60 forks source link

troubles building #19

Closed eminence closed 5 years ago

eminence commented 5 years ago

I am not very familiar with go, so I'm not sure how to debug this.

I git cloned your repository, and then tried to run make build. I get these errors:

achin@bigbox:/nas/achin/devel/mosquitto-exporter$ make build
go build -o bin/mosquitto_exporter -ldflags="-s -w -X main.Version=0.5.0 -X main.GITCOMMIT=`git rev-parse --short HEAD`" github.com/sapcc/mosquitto-exporter
can't load package: package github.com/sapcc/mosquitto-exporter: cannot find package "github.com/sapcc/mosquitto-exporter" in any of:
        /nas/achin/devel/go/src/github.com/sapcc/mosquitto-exporter (from $GOROOT)
        /nas/achin/devel/gopath/src/github.com/sapcc/mosquitto-exporter (from $GOPATH)
Makefile:19: recipe for target 'build' failed
make: *** [build] Error 1

I'm using this version of go:

go version go1.12.4 linux/amd64

Any suggestions?

ArtieReus commented 5 years ago

Did you set the $GOPATH? https://github.com/golang/go/wiki/SettingGOPATH

eminence commented 5 years ago

No, I had not set GOPATH. That fixed the build problem. Thanks

bratekarate commented 4 years ago

This does not work for me. If I set GOPATH to the root project directory, ~it looks in src, not in vendor. If I set GOPATH to the vendor directory, it looks in vendor/src. What am I doing wrong?~

Edit: Ok, I mixed things up a bit. I only got it working now by using the folder structure src/github.com/sapcc/mosquitto-exporter/<project>. Is this really necessary? Can't I just put this project source in any directory? How can I avoid this?