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