简体   繁体   English

去构建找不到包源

[英]go build can't find package sources

I'm trying to build the teamcity prometheus exporter I found in this repo . 我试图建立TeamCity的普罗米修斯出口我在这个发现的回购
In the readme it instructs me to execute the following command which should build the project - docker run --rm -v "$PWD":/go/src/github.com/guidewire/teamcity_exporter -w /go/src/github.com/guidewire/teamcity_exporter -e GOOS=linux -e GOARCH=amd64 golang:1.8 go build -o bin/teamcity_exporter -v 在自述文件中,它指示我执行以下应构建项目的命令docker run --rm -v "$PWD":/go/src/github.com/guidewire/teamcity_exporter -w /go/src/github.com/guidewire/teamcity_exporter -e GOOS=linux -e GOARCH=amd64 golang:1.8 go build -o bin/teamcity_exporter -v

But it fails with the following error - 但是它失败,并显示以下错误-

teamcity_exporter.go:15:2: cannot find package "github.com/guidewire/teamcity-go-bindings" in any of:
    /go/src/github.com/guidewire/teamcity_exporter/vendor/github.com/guidewire/teamcity-go-bindings (vendor tree)
    /usr/local/go/src/github.com/guidewire/teamcity-go-bindings (from $GOROOT)
    /go/src/github.com/guidewire/teamcity-go-bindings (from $GOPATH)
teamcity_exporter.go:16:2: cannot find package "github.com/orcaman/concurrent-map" in any of:
    /go/src/github.com/guidewire/teamcity_exporter/vendor/github.com/orcaman/concurrent-map (vendor tree)
    /usr/local/go/src/github.com/orcaman/concurrent-map (from $GOROOT)
    /go/src/github.com/orcaman/concurrent-map (from $GOPATH)
collector.go:6:2: cannot find package "github.com/prometheus/client_golang/prometheus" in any of:
    /go/src/github.com/guidewire/teamcity_exporter/vendor/github.com/prometheus/client_golang/prometheus (vendor tree)
    /usr/local/go/src/github.com/prometheus/client_golang/prometheus (from $GOROOT)
    /go/src/github.com/prometheus/client_golang/prometheus (from $GOPATH)
teamcity_exporter.go:18:2: cannot find package "github.com/prometheus/common/log" in any of:
    /go/src/github.com/guidewire/teamcity_exporter/vendor/github.com/prometheus/common/log (vendor tree)
    /usr/local/go/src/github.com/prometheus/common/log (from $GOROOT)
    /go/src/github.com/prometheus/common/log (from $GOPATH)
teamcity_exporter.go:19:2: cannot find package "github.com/prometheus/common/version" in any of:
    /go/src/github.com/guidewire/teamcity_exporter/vendor/github.com/prometheus/common/version (vendor tree)
    /usr/local/go/src/github.com/prometheus/common/version (from $GOROOT)
    /go/src/github.com/prometheus/common/version (from $GOPATH)
config.go:8:2: cannot find package "gopkg.in/yaml.v2" in any of:
    /go/src/github.com/guidewire/teamcity_exporter/vendor/gopkg.in/yaml.v2 (vendor tree)
    /usr/local/go/src/gopkg.in/yaml.v2 (from $GOROOT)
    /go/src/gopkg.in/yaml.v2 (from $GOPATH)

I've tried looking around for go package managers and using them to preinstall the packages (went over dep and govendor but both didn't seem fit to my use case) . 我尝试到处寻找go软件包管理器,并使用它们来预安装软件包(经过了depgovendor,但两者似乎都不适合我的用例)。

Also opened an issue in the github repo but there are a few other issues that didn't get any response so I'm not getting my hopes up. 还在github存储库中打开了一个问题 ,但是还有其他一些问题没有得到任何回应,所以我没有寄予希望。

I'm not that familiar with go, so I was hoping someone here might have a clue as to what I'm missing. 我对go不太熟悉,所以我希望这里的某人可能对我所缺少的有所了解。
Thanks! 谢谢!

I would recommend changing go build to go get . 我建议将go build更改为go get That should fetch all the dependencies and will also build the binary and drop it into $GOPATH/bin . 那应该获取所有依赖关系,还将构建二进制文件并将其放入$GOPATH/bin go build expects everything to already be in place. go build期望一切都已经就绪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM