如何修复 gomod:`github.com/stretchrcom/testify@v1.4.0: parsing go.mod: unexpected module path "github.com/stretchr/testify"`

How to fix gomod: `github.com/stretchrcom/testify@v1.4.0: parsing go.mod: unexpected module path "github.com/stretchr/testify"`

当我做 go mod tidy。 我收到以下错误:

go: github.com/stretchrcom/testify@v1.4.0: parsing go.mod: unexpected module path "github.com/stretchr/testify"

此错误是由于在移动到 github.com/stretchr/testify 之前引用 testify 的包造成的。

解决方案是在 go.mod 中添加以下行:

replace github.com/stretchrcom/testify v1.4.0 => github.com/stretchr/testify v1.4.0

如果这是一个直接依赖项,那么建议将正确的依赖项直接添加到您的 go.mod 文件中,即 github.com/stretchr/testify v1.4.0