【问题标题】:go build can't find package sourcesgo build 找不到包源
【发布时间】:2018-11-16 18:27:05
【问题描述】:

我正在尝试构建我在 repo 中找到的 teamcity prometheus 导出器。
在自述文件中,它指示我执行以下应该构建项目的命令 - 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

但它失败并出现以下错误 -

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)

我尝试四处寻找 go 包管理器并使用它们来预安装包(检查了 depgovendor,但两者似乎都不适合我的用例)。

还在 github 存储库中打开了 issue,但还有一些其他问题没有得到任何回应,所以我没有抱太大希望。

我对围棋不太熟悉,所以我希望这里的人可能知道我错过了什么。
谢谢!

【问题讨论】:

    标签: go dependencies godeps


    【解决方案1】:

    我建议将go build 更改为go get。这应该获取所有依赖项,并且还将构建二进制文件并将其放入$GOPATH/bingo build 期望一切都已经到位。

    【讨论】:

    • 太棒了!很高兴听到它。
    • 只是为了确认。我运行go getgo build。我没有尝试 README 中的长命令行。
    • go get 将为您构建它,然后没有理由运行go build
    • 不错!很高兴听到它。
    猜你喜欢
    • 1970-01-01
    • 2012-06-26
    • 2014-03-24
    • 2017-02-10
    • 1970-01-01
    • 2017-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多