[部署日記]GO在Visual Studio Code初次運行時提示go: go.mod file not found in current directory or any parent directory; see 'go help modules'


我裂開,一波未平一波又起...

按照MS教程上填寫

package main

import "fmt"

func main() {
    fmt.Println("Hello World!")
}

 

 

然后無腦搜索教程,其中修改了launch.json無濟於事,按理來說新手入門的話應該VSC的配置文件是不需要修改的。


 

翻了下文檔,發現是  跳  過  新  手  教  程  的  錯  誤  玩  法

在新建新GO項目后,要在當前文件夾執行

go mod init {項目名}

然后進入項目文件夾,執行

go build

 

最后回到VSC運行提示:

Hello World!
Process exiting with code: 0

完事

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM