我正在尝试在CI中调试以下构建错误,其中“ A依赖于B,而B依赖于C而无法构建”。我正在构建不直接依赖于kafkaAvailMonitor.go的数据服务,这使此错误很难跟踪。换一种说法:
数据(我要构建的数据)取决于(?),取决于kafkaAvailMonitor.go
对于开发人员来说,他们只是“去做任何事情”似乎很难解决,但是在发行过程中我不能做到这一点-我必须找到添加依赖项的人员并要求他们对其进行修复。
我知道有一些工具可以可视化依赖关系树和其他更复杂的构建系统,但这似乎是一个非常基本的问题:有什么办法可以查看完整的依赖关系树以查看导致构建问题的原因?
go build -a -v
../../../msgq/kafkaAvailMonitor.go:8:2: cannot find package
"github.com/Shopify/sarama/tz/breaker" in any of:
/usr/lib/go-1.6/src/github.com/Shopify/sarama/tz/breaker (from $GOROOT)
/home/jenkins/go/src/github.com/Shopify/sarama/tz/breaker (from $GOPATH)
/home/jenkins/vendor-library/src/github.com/Shopify/sarama/tz/breaker
/home/jenkins/go/src/github.com/Shopify/sarama/tz/breaker
/home/jenkins/vendor-library/src/github.com/Shopify/sarama/tz/breaker
如果以下内容不是堆栈跟踪,那是什么?
这是Go寻找丢失的包裹的路径的列表。
我不知道谁在导入kafkaAvailMonitor.go
它不是“导入”的,只是部分源代码并已编译。
除非它无法编译(因为需要)github.com/Shopify/sarama/tz/breaker
,否则它不在GOROOT
或中GOPATH
。
不过,请检查直接包装上go list
会返回什么,看看是否kafkaAvailMonitor
有提及。
go list
可以显示您的包直接依赖的包,或完整的传递依赖集。
% go list -f '{{ .Imports }}' github.com/davecheney/profile
[io/ioutil log os os/signal path/filepath runtime runtime/pprof]
% go list -f '{{ .Deps }}' github.com/davecheney/profile
[bufio bytes errors fmt io io/ioutil log math os os/signal path/filepath reflect run
然后,您可以编写go list脚本以列出所有依赖项。例如,
请参见Noel Cower()的bash脚本nilium
#!/usr/bin/env bash
# Usage: lsdep [PACKAGE...]
#
# Example (list github.com/foo/bar and package dir deps [the . argument])
# $ lsdep github.com/foo/bar .
#
# By default, this will list dependencies (imports), test imports, and test
# dependencies (imports made by test imports). You can recurse further by
# setting TESTIMPORTS to an integer greater than one, or to skip test
# dependencies, set TESTIMPORTS to 0 or a negative integer.
: "${TESTIMPORTS:=1}"
lsdep_impl__ () {
local txtestimps='{{range $v := .TestImports}}{{print . "\n"}}{{end}}'
local txdeps='{{range $v := .Deps}}{{print . "\n"}}{{end}}'
{
go list -f "${txtestimps}${txdeps}" "$@"
if [[ -n "${TESTIMPORTS}" ]] && [[ "${TESTIMPORTS:-1}" -gt 0 ]]
then
go list -f "${txtestimps}" "$@" |
sort | uniq |
comm -23 - <(go list std | sort) |
TESTIMPORTS=$((TESTIMPORTS - 1)) xargs bash -c 'lsdep_impl__ "$@"' "$0"
fi
} |
sort | uniq |
comm -23 - <(go list std | sort)
}
export -f lsdep_impl__
lsdep_impl__ "$@"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句