gpt4 book ai didi

go build 找不到包源

转载 作者:IT王子 更新时间:2023-10-29 01:53:47 29 4
gpt4 key购买 nike

我正在尝试构建我在此 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 但两者似乎都不适合我的用例)。

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

我对 go 不是很熟悉,所以我希望这里有人能知道我遗漏了什么。
谢谢!

最佳答案

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

关于go build 找不到包源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53343464/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com