stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.5k stars 1.56k forks source link

Cannot install testify using go mod #745

Open kolaente opened 5 years ago

kolaente commented 5 years ago

Hi, I tried to install testify using go get github.com/stretchr/testify inside a library which uses go mod. This works fine, testify is added to the go.mod and go.sum files. But, an entry containing gopkg.in/check.v1 is added to the go.sum file. This also happens when I delete the go.mod and go.sum files and start again (go mod init and so on).

However, when I try to reference this project in another one (a project which uses go mod, using go get -u ..., it fails with the following error:

go: gopkg.in/stretchr/testify.v1@v1.3.0: go.mod has non-....v1 module path "github.com/stretchr/testify" at revision v1.3.0
go get: error loading module requirements

The library I try to use in my own project is xormigrate.

I don't understand why there is gopkg.in/check.v1 while there is no reference anywhere to it.

This could also be an issue with the way go modules work.

olofwalker commented 5 years ago

I'm seeing this as well....

qiudesong commented 5 years ago

me too ...

kolaente commented 5 years ago

Looks like this stackoverflow question pretty much sums the problem up. The problem for me here is I can't update any of my dependencies since go will complain about github.com/stretchr/testify and stop everything.

It looks like go is expecting the package in v1 in a path like github.com/stretchr/testify/v1 and not github.com/stretchr/testify.v1 or so. Which is weired, since the article on go modules states modules should only do this starting at v2+, not v1 or below.