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

$ 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.

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

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮