vscode golang debug配置

  • 在项目根目录下创建.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"] // 启动参数
        }
    ]
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容