没有了解过 go ,今天需要运行一个 go 的程序,按照这个教程 https://www.bt.cn/bbs/thread-17882-1-1.html 部署了环境一切正常,但是运行:go run main.go 的时候,出现如下的问题: main.go:23:2: no required module provides package github.com/shirou/gopsutil/cpu: go.mod file not found in current directory or any parent directory; see 'go help modules' main.go:24:2: no required module provides package github.com/shirou/gopsutil/mem: go.mod file not found in current directory or any parent directory; see 'go help modules' main.go:25:2: no required module provides package github.com/shirou/gopsutil/net: go.mod file not found in current directory or any parent directory; see 'go help modules'
输入:go help modules 后提示如下 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.
希望大伙可以帮一下我,谢谢。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.