【Go】go get is no longer supported outside a module

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.mod 文件

# 生成 mod 文件(切换到模块根目录)
go mod init modulename

# 清理无效依赖,增加缺失依赖
go mod tidy

你可能感兴趣的:(golang,开发语言,后端)