首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >$GOPATH/src/...供应商/..。版本不同

$GOPATH/src/...供应商/..。版本不同
EN

Stack Overflow用户
提问于 2017-08-23 22:36:27
回答 1查看 263关注 0票数 2

我的项目使用Go 1.8,依赖于github.com/stretchr/testify。我使用go get -u github.com/stretchr/testify检索了最新版本,$GOPATH/src中的版本似乎是正确的。

我在Gopkg.toml中添加了最新的版本号作为约束

代码语言:javascript
复制
[[constraint]]
  name = "github.com/stretchr/testify"
  version = "1.1.4"

然后运行dep ensure -updatedep status来更新vendor目录(dep status的输出):

代码语言:javascript
复制
github.com/stretchr/testify  ^1.1.4  v1.1.4  69483b4  69483b4  1   

在文件github.com/stretchr/testify/assert/assertions.go中,$GOPATH/src中的版本包含函数PanicsWithValue

代码语言:javascript
复制
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的版本中,该函数缺失:

代码语言:javascript
复制
func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
    // ...
}

func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
    // ...
}

我做错了什么?我想在我的测试中使用函数PanicsWithValue。我甚至尝试删除整个vendor目录并重新构建它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-23 22:43:41

通过将版本固定到v1.1.4,您就明确地告诉dep使用不包含您想要的功能的版本(查看GitHub上的证明包的历史记录- v1.1.4是去年9月的版本,PanicsWithValue是今年6月添加的)。如果你解锁版本(version = "*"),它应该使用包含PanicsWithValue的master@HEAD。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45842740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档