dongxing5525 2017-08-23 14:36
浏览 198
已采纳

$ GOPATH / src /…和vendor /…版本不同

My project, using Go 1.8, has a dependency on github.com/stretchr/testify. I retrieved the latest using go get -u github.com/stretchr/testify and the version in $GOPATH/src appears to be correct.

I added the latest version number as a contraint in Gopkg.toml:

[[constraint]]
  name = "github.com/stretchr/testify"
  version = "1.1.4"

I then ran dep ensure -update and then dep status to update the vendor directory (output of dep status):

github.com/stretchr/testify  ^1.1.4  v1.1.4  69483b4  69483b4  1   

The version in $GOPATH/src contains, in the file github.com/stretchr/testify/assert/assertions.go, the function 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 {
    // ...
}

but in the version in vendor, that function is missing:

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

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

What am I doing wrong? I would like to use the function PanicsWithValue in my testing. I even tried deleting the entire vendor directory and rebuilding it.

  • 写回答

1条回答 默认 最新

  • duancai7002 2017-08-23 14:43
    关注

    By pinning the version to v1.1.4, you're specifically telling dep to use a version that does not include the feature you want (check the history of the testify package on GitHub - v1.1.4 is from last September, PanicsWithValue was added this past June). If you unpin the version (version = "*") it should use master@HEAD which includes PanicsWithValue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 如何通过代码传输视频到亚马逊平台
  • ¥15 php查询mysql数据库并显示至下拉列表中
  • ¥15 freertos下使用外部中断失效
  • ¥15 输入的char字符转为int类型,不是对应的ascall码,如何才能使之转换为对应ascall码?或者使输入的char字符可以正常与其他字符比较?
  • ¥15 devserver配置完 启动服务 无法访问static上的资源
  • ¥15 解决websocket跟c#客户端通信
  • ¥30 Python调用dll文件输出Nan重置dll状态
  • ¥15 浮动div的高度控制问题。
  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题