vscode 配置
配置golang 环境,参考
https://learn.microsoft.com/zh-cn/azure/developer/go/configure-visual-studio-code
debug
1.工作目录下增加
.vscode/launch.json
2.配置launch.json
以go-kratos 框架,创建demo
示例:
{
// 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 Package",
"type": "go",
"request": "launch",
"mode": "auto",
// "skipFiles": ["${workspaceFolder}/cmd/service/wire.go"],
"program": "${workspaceFolder}/cmd/service",
"args": ["-f", "${workspaceFolder}/configs/config.yaml"]
}
]
}
- 调试
-
请自配使用kratos 能正常运行后,进行vscode 调试
kratos run 或者 go run ./cmd/service/main.go ./cmd/service/wire_gen.go -f ./configs/config.yaml -
F5运行
参考
环境配置转自
https://learn.microsoft.com/zh-cn/azure/developer/go/configure-visual-studio-code
launch.json 示例及各参数说明
https://segmentfault.com/a/1190000018671207
https://github.com/golang/vscode-go/blob/master/docs/debugging.md