- 在项目根目录下创建.vscode/launch.json
- 输入类似配置保存
{
// 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",
"buildFlags":"-mod=vendor", // 使用vendor模式
"env": {"xxxEnv":"on"}, // 环境变量
"args": ["-config","xxx.toml"] // 启动参数
}
]
}
网友评论