无法安装go模块,使用get-u和install [已关闭]

aiazj4mn  于 2022-12-28  发布在  Go
关注(0)|答案(1)|浏览(236)

这个问题是由打字错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
21小时前关门了。
Improve this question
我想安装go-fastping。但是当我尝试时,发生了这种情况:第一个月

go: go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.
        To build and install a command, use 'go install' with a version,
        like 'go install example.com/cmd@latest'
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

所以我改为安装:go install github.com/tatsushid/go-fastping

Try 'go install github.com/tatsushid/go-fastping@latest' to install the latest version ```

and after I did changed to: `go install github.com/tatsushid/go-fastping@latest`

it worked but when I try to add it in the code it says that the module is not installed.
dpiehjr4

dpiehjr41#

您的项目很可能没有go.mod文件。
在项目的根目录中运行go mod init <module-name>创建一个模块,然后运行go get -u github.com/tatsushid/go-fastping将此依赖项添加到项目中。

相关问题