简体   繁体   English

golang测试错误:在以下任何位置都找不到软件包“ github.com/stretchr/testify/assert”:

[英]golang test error: cannot find package “github.com/stretchr/testify/assert” in any of:

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: 当我尝试运行“ 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]

So it appears the last line is the issue, where it says in .../lib/briteverify it cannot find github.com/stretchr/testify/assert. 因此,似乎最后一行是问题所在,它在... / lib / briteverify中表示找不到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? 有什么想法吗?

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. 您需要同时导入软件包并运行go get github.com/package/path来安装软件包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何避免找不到包“ github.com/golang/protobuf/jsonpb”错误 - How to avoid cannot find package “github.com/golang/protobuf/jsonpb” error 在以下任何一个中找不到包“github.com/gorilla/mux”: - cannot find package “github.com/gorilla/mux” in any of: 如何解决gomod:`github.com/stretchrcom/testify@v1.4.0:解析go.mod:意外的模块路径“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”` 软件包github.com/matcornic/hermes/v2:在以下任何位置都找不到软件包“ github.com/matcornic/hermes/v2”: - package github.com/matcornic/hermes/v2: cannot find package “github.com/matcornic/hermes/v2” in any of: 构建时在golang中找不到包“github.com/user../../” - cannot find package “github.com/user../../” in golang while building 在以下任何一个中都找不到 package “github.com/jackc/pgx/v4”: - cannot find package “github.com/jackc/pgx/v4” in any of: 无法安装 bleve,在任何地方都找不到 package “github.com/blevesearch/zap/v11” - Unable to install bleve, cannot find package “github.com/blevesearch/zap/v11” in any of 下载 go-redis 包时报错找不到包“github.com/go-redis/redis/v8” - Error cannot find package "github.com/go-redis/redis/v8" when downloading go-redis package stretchr/testify/assert 只提供堆栈跟踪,缺少实际的错误消息 - stretchr/testify/assert just giving stack trace, missing actual error message 如何用stretchr/testify测试小数的相等性? - How to test equality of a decimal with stretchr/testify?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM