这个报错是因为Go 1.16版本之后,推荐使用Go Modules来管理依赖,而不再支持在非模块化的项目中使用go get命令。

要解决这个问题,你可以按照以下步骤进行操作:

  1. 确保你的项目目录下存在go.mod文件,如果不存在,可以通过运行go mod init命令来初始化一个新的模块。

  2. 使用go install命令来安装依赖,例如go install example.com/cmd@latest。请将example.com/cmd替换为你需要安装的依赖包的路径。

  3. 如果你不确定依赖包的路径,可以在命令行中运行go help getgo help install来获取更多帮助信息。

希望这能帮助到你解决问题!

go程序报错rootcentos21 go# go get govaluatego gomod 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

原文地址: https://www.cveoy.top/t/topic/h3Un 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录