登录
首页 >  Golang >  Go问答

查找主模块失败:请查看"前往帮助模块"

来源:stackoverflow

时间:2024-02-22 23:24:26 461浏览 收藏

欢迎各位小伙伴来到golang学习网,相聚于此都是缘哈哈哈!今天我给大家带来《查找主模块失败:请查看"前往帮助模块"》,这篇文章主要讲到等等知识,如果你对Golang相关的知识非常感兴趣或者正在自学,都可以关注我,我会持续更新相关文章!当然,有什么建议也欢迎在评论留言提出!一起学习!

问题内容

我最近开始使用 go。我在 vscode 上安装了 go 的扩展,我可以使用一些命令,例如 go rungo build 但当我运行 go test 时出现以下错误:

go:找不到主模块;请参阅“转到帮助模块”

虽然我有一个 *_test.go 文件。

当我运行 go help 模块时,我得到以下输出:

Modules are how Go manages dependencies.

A module is a collection of packages that are released, versioned, and
distributed together. Modules may be downloaded directly from version control
repositories or from module proxy servers.

For a series of tutorials on modules, see
https://golang.org/doc/tutorial/create-module.

For a detailed reference on modules, see https://golang.org/ref/mod.

By default, the go command may download modules from https://proxy.golang.org.
It may authenticate modules using the checksum database at
https://sum.golang.org. Both services are operated by the Go team at Google.
The privacy policies for these services are available at
https://proxy.golang.org/privacy and https://sum.golang.org/privacy,
respectively.

The go command's download behavior may be configured using GOPROXY, GOSUMDB,
GOPRIVATE, and other environment variables. See 'go help environment'
and https://golang.org/ref/mod#private-module-privacy for more information.

解决方案


您必须先初始化项目,然后才能运行测试:

go mod init puppy

https://golang.org/cmd/go#hdr-Module_maintenance

文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《查找主模块失败:请查看"前往帮助模块"》文章吧,也可关注golang学习网公众号了解相关技术文章。

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>