go - $GOPATH/src/... 和 vendor/... 版本不同

标签 go versioning vendor

我的项目使用 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,您明确告诉 dep 使用不包含您想要的功能的版本(检查 GitHub 上 testify 包的历史 - v1. 1.4 来自去年 9 月,PanicsWithValue 是今年 6 月添加的)。如果您取消固定版本 (version = "*"),它应该使用包含 PanicsWithValue 的 master@HEAD。

关于go - $GOPATH/src/... 和 vendor/... 版本不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45842740/

相关文章:

go - 节点结构 slice 中未定义的属性

laravel - 如何从供应商目录生成 laravel composer.json?

javascript - Foundation Framework Sticky Topbar 不粘

javascript - 如何使用 javascript_include_tag 从 vendor/assets/javascripts 添加特定于 Controller 的 javascript?

google-chrome - 当我从 chrome websocket 发送 127+ 个字符时,我的 golang 服务器不能看到超过 126 个

pointers - 跨包将结构传递给函数

linux - cgo 交叉编译找不到库

database-design - 如何存储历史数据

ant - 询问用户是|否输入

Flutter 强制更高的包依赖版本