Build Error: go build -o c:\Users\13283\Desktop\godemo\__debug_bin3410376605.exe -gcflags all=-N -l .
go: go.mod file not found in current directory or any parent directory; see 'go help modules' (exit status 1)
原因分析:
go 的環(huán)境配置問題。與 golang 的包管理有關(guān)
處理方案:
如果你是 Windows 系統(tǒng),快捷鍵 “Win+R”,輸入cmd,打開終端。輸入:
go env -w GO111MODULE=auto
解釋:
GO111MODULE 是 Go 1.11 引入的新版模塊管理方式。
GO111MODULE 環(huán)境變量用于開啟或關(guān)閉 Go 語言中的模塊支持,它有 off、on、auto 三個(gè)可選值,默認(rèn)為 auto。
GO111MODULE=off
無模塊支持,go 會(huì)從 $GOPATH 文件夾和 vendor 目錄中尋找依賴項(xiàng)。
GO111MODULE=on
模塊支持,go 忽略 $GOPATH 文件夾,只根據(jù) go.mod 下載依賴。
GO111MODULE=auto
在 $GOPATH/src 外層且根目錄有 go.mod 文件時(shí),開啟模塊支持;否者無模塊支持
?文章來源:http://www.zghlxwxcb.cn/news/detail-699934.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-699934.html
到了這里,關(guān)于[Go 報(bào)錯(cuò)] go: go.mod file not found in current directory or any parent directory的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!