go.mod file not found in current directory or any parent directory; see 'go help modules'


go的环境设置问题,执行

go env -w GO111MODULE=auto

我的环境:Windows 7, Go 1.17

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo>cd day01

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01>cd helloworld

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>go build
go: go.mod file not found in current directory or any parent directory; see 'go help modules'

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>where go.exe
D:\Apps\Go\bin\go.exe

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>go.exe build
go: go.mod file not found in current directory or any parent directory; see 'go help modules'

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>go env -w GO111MODULE=auto

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>go build

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>go version
go version go1.17 windows/amd64

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>dir
 驱动器 D 中的卷没有标签。
 卷的序列号是 C61D-1F2E

 D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld 的目录

2021/09/06  21:52    <DIR>          .
2021/09/06  21:52    <DIR>          ..
2021/09/06  21:52         1,925,120 helloworld.exe
2021/09/06  21:41                79 main.go
               2 个文件      1,925,199 字节
               2 个目录 71,544,717,312 可用字节

D:\Apps\GOPATH\src\code.oldboyedu.com\studygo\day01\helloworld>helloworld.exe
Hello World!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM