gpt4 book ai didi

golang测试报错: cannot find package "github.com/stretchr/testify/assert" in any of:

转载 作者:IT王子 更新时间:2023-10-29 01:52:26 27 4
gpt4 key购买 nike

我的导入如下所示:

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。但是,我将其作为导入,所以我不知道为什么会抛出此错误。有什么想法吗?

最佳答案

以后将答案移至此处以供其他人使用。

您需要导入包并运行 go get github.com/package/path 来安装包。

关于golang测试报错: cannot find package "github.com/stretchr/testify/assert" in any of:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42254513/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com