【发布时间】:2018-02-01 05:19:42
【问题描述】:
我的项目使用 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
$GOPATH/src 中的版本在文件github.com/stretchr/testify/assert/assertions.go 中包含函数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 目录并重建它。
【问题讨论】:
-
没什么。 v1.1.4(最新标签)是从去年九月开始的。 PanicsWithValue 于 6 月 1 日添加。
-
有没有办法强制
dep使用$GOPATH/src中的版本? -
我对@987654341@ 不是很熟悉,但它看起来像是全有或全无。您可以完全删除约束 (
version = "*"),它应该使用 master@HEAD。 -
我会试试的。谢谢。
-
转换为答案。
标签: go versioning vendor