go: cannot determine module path for source directory E:\goland_workplace\goblog\github.com\ruasib\goblog (outside GOPATH, module path must be specified)

报错信息:

go: cannot determine module path for source directory E:\goland_workplace\goblog\github.com\ruasib\goblog (outside GOPATH, module path must be specified)

解决方法:

创建 module:

在src(源文件,就是你写代码的地方)目录下执行命令:

 go mod init 项目名称

在控制台,执行如下命令 创建一个名为demo的module包,对应目录会生成 一个go.mod文件

 go mod init demo

生成文件go.mod:

文件内容:

其中对应的 module 为项目名称,即之前你执行go mod init demo中的demo

go 后面的数字为你现在使用的go 版本信息

posted @ 2021-06-06 22:34  背影g  阅读(5580)  评论(0编辑  收藏  举报