# vscode golang debug程序配置方法 **Published by:** [ijaa](https://paragraph.com/@ijaa/) **Published on:** 2022-01-12 **URL:** https://paragraph.com/@ijaa/vscode-golang-debug ## Content 1.在项目根目录下的.vscode目录创建launch.json文件 2.文件内容模版如下:{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "mode": "auto", "program": "${workspaceRoot}/main.go", // main.go文件路径 "buildFlags":"-mod=vendor", // 使用vendor模式或者为空 "env": {"xxxEnv":"on"}, // 自定义环境变量 "args": ["-config","xxx.toml"] // 自定义启动参数 } ] } 3.上述模版中的buildFlags,env,args可根据具体编译及运行需要进行调整 ## Publication Information - [ijaa](https://paragraph.com/@ijaa/): Publication homepage - [All Posts](https://paragraph.com/@ijaa/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@ijaa): Subscribe to updates