千家信息网

编译postgres exporter遇到的问题该如何解决

发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,编译postgres exporter遇到的问题该如何解决,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。在编译prometheus的
千家信息网最后更新 2024年09月22日编译postgres exporter遇到的问题该如何解决

编译postgres exporter遇到的问题该如何解决,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

在编译prometheus的postgres exporter时,遇到了以下错误:

[parallels@centos7 postgres_exporter]$ go run mage.go binarygo: finding github.com/magefile/mage v1.10.0go: downloading github.com/magefile/mage v1.10.0go: extracting github.com/magefile/mage v1.10.0Error determining list of magefiles: failed to list non-mage gofiles: exit status 1: go: cannot find main module, but found vendor/vendor.json in /home/parallels/Go/src/postgres_exporter        to create a module there, run:        go mod initexit status 1

经过调查,发现是之前配置的go mod环境变量导致的编译失败,具体原因还有待研究。

于是手工通过关闭GO111MODULE环境变量编译成功,如下:

[parallels@centos7 postgres_exporter]$ export GO111MODULE=off[parallels@centos7 postgres_exporter]$ go run mage.go binary2020/09/15 01:17:33 exec: git rev-parse --abbrev-ref HEAD2020/09/15 01:17:33 exec: git rev-parse HEAD2020/09/15 01:17:33 exec: git describe --dirty2020/09/15 01:17:33 exec: git describe --abbrev=02020/09/15 01:17:34 exec: go list ./...golang.org/x/tools/covergithub.com/pelletier/go-buffruneiogithub.com/google/shlexgithub.com/mattn/goverallsgithub.com/nicksnyder/go-i18n/i18n/languagegithub.com/alecthomas/unitsgithub.com/nicksnyder/go-i18n/i18n/translationgithub.com/pelletier/go-tomlgopkg.in/yaml.v2github.com/nicksnyder/go-i18n/i18n/bundlegithub.com/nicksnyder/go-i18n/i18nFinished 1 of 6gopkg.in/alecthomas/kingpin.v3-unstablegithub.com/alecthomas/gometalintergithub.com/kardianos/govendor/promptgolang.org/x/sys/unixgithub.com/dchest/safefilegithub.com/kardianos/govendor/internal/pathosgithub.com/Bowery/promptgithub.com/kardianos/govendor/internal/vosgithub.com/kardianos/govendor/clipromptgithub.com/kardianos/govendor/internal/vfilepathgithub.com/kardianos/govendor/pkgspecgithub.com/kardianos/govendor/vendorfilegithub.com/kardianos/govendor/vcsgithub.com/pkg/errorsgolang.org/x/tools/go/vcsFinished 2 of 6github.com/kardianos/govendor/contextgithub.com/wadey/gocovmergegithub.com/kardianos/govendor/migrateFinished 3 of 6github.com/kardianos/govendor/helpgithub.com/kardianos/govendor/rungithub.com/kardianos/govendorgithub.com/tmthrgd/go-bindata/internal/identifiergithub.com/tmthrgd/go-bindatagithub.com/tmthrgd/go-bindata/go-bindataFinished 4 of 6Finished 5 of 6github.com/nbutton23/zxcvbn-go/matchgolang.org/x/tools/go/ast/astutilgolang.org/x/tools/go/buildutilgolang.org/x/tools/go/loadergithub.com/nbutton23/zxcvbn-go/datagithub.com/GoASTScanner/gasgithub.com/nbutton23/zxcvbn-go/adjacencygithub.com/GoASTScanner/gas/outputgithub.com/nbutton23/zxcvbn-go/utils/mathgithub.com/nbutton23/zxcvbn-go/entropygithub.com/nbutton23/zxcvbn-go/frequencygithub.com/nbutton23/zxcvbn-go/scoringgithub.com/kisielk/gotoolgithub.com/nbutton23/zxcvbn-go/matchinggithub.com/ryanuber/go-globgithub.com/nbutton23/zxcvbn-gogithub.com/GoASTScanner/gas/rulesgithub.com/GoASTScanner/gas/cmd/gasFinished 6 of 6golang.org/x/tools/cmd/gotypegithub.com/opennota/check/cmd/structcheckFinished 1 of 25Finished 2 of 25github.com/alexflint/go-scalargithub.com/walle/lllgithub.com/alexflint/go-arggithub.com/walle/lll/cmd/lllhonnef.co/go/tools/deprecatedgolang.org/x/tools/go/types/typeutilhonnef.co/go/tools/versionhonnef.co/go/tools/ssaFinished 3 of 25honnef.co/go/tools/callgraphhonnef.co/go/tools/ssa/ssautilgolang.org/x/text/transformhonnef.co/go/tools/linthonnef.co/go/tools/lint/lintutilhonnef.co/go/tools/staticcheck/vrpgolang.org/x/text/widthhonnef.co/go/tools/internal/sharedcheckhonnef.co/go/tools/simplegithub.com/mdempsky/unconverthonnef.co/go/tools/callgraph/statichonnef.co/go/tools/unusedhonnef.co/go/tools/functionshonnef.co/go/tools/staticcheckhonnef.co/go/tools/cmd/megacheckFinished 4 of 25Finished 5 of 25github.com/jgautheron/goconstgithub.com/jgautheron/goconst/cmd/goconstFinished 6 of 25Finished 7 of 25honnef.co/go/tools/cmd/gosimplegolang.org/x/tools/go/ssamvdan.cc/lintgolang.org/x/tools/go/ssa/ssautilFinished 8 of 25mvdan.cc/interfacer/checkmvdan.cc/interfacergolang.org/x/tools/go/callgraphgolang.org/x/tools/go/callgraph/chagolang.org/x/tools/go/callgraph/rtamvdan.cc/unparam/checkmvdan.cc/unparamFinished 9 of 25github.com/opennota/check/cmd/varcheckFinished 10 of 25github.com/dnephin/govet/internal/whitelistgithub.com/dnephin/govet/internal/cfggithub.com/dnephin/govetFinished 11 of 25honnef.co/go/tools/cmd/unusedFinished 12 of 25Finished 13 of 25github.com/alecthomas/gocyclogolang.org/x/tools/importsFinished 14 of 25golang.org/x/tools/cmd/goimportsgithub.com/mdempsky/malignedFinished 15 of 25github.com/tsenart/deadcodeFinished 16 of 25github.com/mibk/dupl/suffixtreegithub.com/mibk/dupl/syntaxgithub.com/mibk/dupl/syntax/golanggithub.com/mibk/dupl/printerFinished 17 of 25github.com/mibk/dupl/jobgithub.com/mibk/duplgithub.com/client9/misspellFinished 18 of 25github.com/alexkohler/nakedretgithub.com/client9/misspell/cmd/misspellFinished 19 of 25golang.org/x/tools/container/intsetsgolang.org/x/tools/go/pointergithub.com/stripe/safesqlFinished 20 of 25golang.org/x/tools/go/gcimporter15golang.org/x/tools/go/gcexportdatagolang.org/x/lintFinished 21 of 25github.com/golang/lint/golintgithub.com/kisielk/errcheck/internal/errcheckgithub.com/kisielk/errcheckFinished 22 of 25github.com/gordonklaus/ineffassignFinished 23 of 25Finished 24 of 25honnef.co/go/tools/cmd/staticcheckFinished 25 of 25Building /home/parallels/Go/src/postgres_exporter/bin/postgres_exporter_v0.0.0_linux-amd64/postgres_exporter[parallels@centos7 postgres_exporter]$

关于编译postgres exporter遇到的问题该如何解决问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。

0