dsx666666
2017-02-15 16:11
浏览 856
已采纳

golang测试错误:在以下任何位置都找不到软件包“ 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?

图片转代码服务由CSDN问答提供 功能建议

我的导入如下所示:

  import(\  n“测试” 
 
“ github.com/stretchr/testify/assert” 
)
   
 
 

当我尝试运行“ go test”时,我得到了 错误消息:

 在以下任何位置都找不到软件包“ github.com/stretchr/testify/assert”:
 / Users / [用户名] / go / src / github  .com / [group_name] / [project_name] /vendor/github.com/stretchr/testify/assert(供应商树)
 / usr / local / go / src / github.com / stretchr / testify / assert(来自$ GOROOT  )
 / Users / [用户名] /go/src/github.com/stretchr/testify/assert(来自$ GOPATH)
FAIL github.com/[group_name]/[project_name]/lib/briteverify [设置失败] \  n   
 
 

所以似乎最后一行是问题所在,它在... / lib / briteverify中说找不到github.com/stretchr/testify/assert。 但是,我将此作为导入文件,所以不知道为什么会引发此错误。 有什么想法吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doue1925 2017-02-15 16:25
    已采纳

    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.

    打赏 评论

相关推荐 更多相似问题