go mod init报错go: cannot determine module path for source directory

错误信息

go: cannot determine module path for source directory /opt/test/hello (outside GOPATH, module path must be specified)

解决办法:指定项目名

go mod init myproject