英文:
golang test error: cannot find package "github.com/stretchr/testify/assert" in any of:
问题
我的翻译结果如下:
我的导入代码如下所示:
import (
"testing"
"github.com/stretchr/testify/assert"
)
当我尝试运行 go test
时,我收到以下错误信息:
cannot find package "github.com/stretchr/testify/assert" in any of:
/Users/[username]/go/src/github.com/[group_name]/[project_name]/vendor/github.com/stretchr/testify/assert (vendor tree)
/usr/local/go/src/github.com/stretchr/testify/assert (from $GOROOT)
/Users/[username]/go/src/github.com/stretchr/testify/assert (from $GOPATH)
FAIL github.com/[group_name]/[project_name]/lib/briteverify [setup failed]
所以看起来问题出在最后一行,它说在 .../lib/briteverify 中找不到 github.com/stretchr/testify/assert。然而,我已经将其作为导入项,所以不知道为什么会出现这个错误。有什么想法吗?
英文:
My import looks like this below:
import (
"testing"
"github.com/stretchr/testify/assert"
)
when I try try running 'go test' I get the error message:
cannot find package "github.com/stretchr/testify/assert" in any of:
/Users/[username]/go/src/github.com/[group_name]/[project_name]/vendor/github.com/stretchr/testify/assert (vendor tree)
/usr/local/go/src/github.com/stretchr/testify/assert (from $GOROOT)
/Users/[username]/go/src/github.com/stretchr/testify/assert (from $GOPATH)
FAIL github.com/[group_name]/[project_name]/lib/briteverify [setup failed]
So it appears the last line is the issue, where it says in .../lib/briteverify it cannot find github.com/stretchr/testify/assert. However, I have this as an import so I don't know why it would throw this error. Any thoughts?
答案1
得分: 17
你需要导入该包并运行go get github.com/package/path
来安装该包。
英文:
Moving the answer here for others in the future.
You need to both import the package and run go get github.com/package/path
to install the package.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论