go_vscode_debug

  1. go 源代码

//调试

json 复制代码
{
	"name": "Debug ***",
	"type": "go",
	"request": "launch",
	"mode": "debug", // 调试模式(自动检测或指定)
	"program": "${workspaceFolder}/apps/eapd/main.go", // 可执行文件路径
	"args": [ // 命令行参数(需拆分为数组元素)
		"-service-hostname=127.0.0.1",
		"-port=9502",
		"-etcd-endpoints=http://127.0.0.1:9597",
		"-etcd-user=***",
		"-etcd-password=*****",
		"-database-driver=PostgreSQL Unicode(x64)",
		"-affinity-label=",
		"-anti-affinity-label=",
		"-redirect-stderr=yes",
		"--debug=yes"
	],
	"env": {}, // 如需环境变量,可在此添加(如 ETCD 配置可能依赖环境变量)
	"cwd": "${workspaceFolder}", // 工作目录
	"buildFlags": "", // 编译选项(如需要优化或调试符号)
	"showLog": true // 显示调试日志(可选)
}
  1. go 二进制

//前提:带调试信息

cmd 复制代码
go build -gcflags="-N -l" -o D:/path/to/**.exe

//调试二进制

json 复制代码
{
    "name": "Debug ** (Binary)",
    "type": "go",
    "request": "launch",
    "mode": "exec", // 指定调试已编译的二进制
    "program": "${workspaceFolder}/bin/**.exe", // 绝对路径(注意转义)
    "args": [ // 命令行参数(拆分为数组元素)
        "-service-hostname=127.0.0.1",
        "-port=9502",
        "-etcd-endpoints=http://127.0.0.1:9597",
        "-etcd-user=caxaplm",
        "-etcd-password=***",
        "-database-driver=PostgreSQL Unicode(x64)",
        "-affinity-label=",
        "-anti-affinity-label=",
        "-redirect-stderr=yes",
        "--debug=yes"
    ],
    "cwd": "${workspaceFolder}",
    "dlvFlags": ["--check-go-version=false"], // 忽略版本检查(可选)
    "buildFlags": "" // 无需编译,直接调试
}
  1. 附加

//前提:带调试信息

cmd 复制代码
go build -gcflags="-N -l" -o D:/path/to/**.exe
json 复制代码
 {
    "name": "Attach to Process",
    "type": "go",
    "request": "attach",
    "mode": "local",
    "processId": "${command:pickProcess}",   //弹出进程搜索框
 },
相关推荐
一点程序1 天前
基于SpringBoot的选课调查系统
java·spring boot·后端·选课调查系统
怪兽源码1 天前
基于SpringBoot的选课调查系统
java·spring boot·后端·选课调查系统
csdn_aspnet1 天前
ASP.NET Core 中的依赖注入
后端·asp.net·di·.net core
昊坤说不出的梦1 天前
【实战】监控上下文切换及其优化方案
java·后端
疯狂踩坑人1 天前
【Python版 2026 从零学Langchain 1.x】(二)结构化输出和工具调用
后端·python·langchain
橘子师兄1 天前
C++AI大模型接入SDK—ChatSDK封装
开发语言·c++·人工智能·后端
@ chen1 天前
Spring事务 核心知识
java·后端·spring
一点技术1 天前
基于SpringBoot的选课调查系统
java·spring boot·后端·选课调查系统
RANCE_atttackkk1 天前
Springboot+langchain4j的RAG检索增强生成
java·开发语言·spring boot·后端·spring·ai·ai编程
好好研究1 天前
Spring Boot - Thymeleaf模板引擎
java·spring boot·后端·thymeleaf