1 问题
新创建的golang项目,使用 go mod init 命令时出现 cannot determine module path for source directory xxxxxxx (outside GOPATH, module path must be specified)
2 解决方案
这是因为go mod init 初始化项目时,需要定义一个 module ,当打开一个 go.mod 文件,就会发现第一行就有
module ProjectName
因此,在执行 go mod init 时需要定义 module,如:
go mod init ProjectName