我的项目使用Go 1.8,依赖于github.com/stretchr/testify。我使用go get -u github.com/stretchr/testify检索了最新版本,$GOPATH/src中的版本似乎是正确的。
我在Gopkg.toml中添加了最新的版本号作为约束
[[constraint]]
name = "github.com/stretchr/testify"
version = "1.1.4"然后运行dep ensure -update和dep status来更新vendor目录(dep status的输出):
github.com/stretchr/testify ^1.1.4 v1.1.4 69483b4 69483b4 1 在文件github.com/stretchr/testify/assert/assertions.go中,$GOPATH/src中的版本包含函数PanicsWithValue
func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
// ...
}
func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
// ...
}
func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
// ...
}但在vendor的版本中,该函数缺失:
func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
// ...
}
func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
// ...
}我做错了什么?我想在我的测试中使用函数PanicsWithValue。我甚至尝试删除整个vendor目录并重新构建它。
发布于 2017-08-23 22:43:41
通过将版本固定到v1.1.4,您就明确地告诉dep使用不包含您想要的功能的版本(查看GitHub上的证明包的历史记录- v1.1.4是去年9月的版本,PanicsWithValue是今年6月添加的)。如果你解锁版本(version = "*"),它应该使用包含PanicsWithValue的master@HEAD。
https://stackoverflow.com/questions/45842740
复制相似问题