主要是代码调试用的。
主函数配置文件:
{
"name": "main.go",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceRoot}/main.go",
"cwd": "${workspaceRoot}",
"env": {
"http_proxy": ""
},
"args": [
"-cfg",
"${workspaceRoot}/config/dev/config.toml",
"-in",
"${workspaceRoot}/config/project/project.toml",
],
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 512,
"maxArrayValues": 64,
"maxStructFields": -1
}
}
单元测试配置文件:
{
"name": "go test",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${file}",
"env": {
"http_proxy": ""
},
"args": [
"-cfg",
"${workspaceRoot}/config/dev/config.toml",
"-in",
"${workspaceRoot}/config/project/project.toml",
],
"showLog": true,
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 512,
"maxArrayValues": 64,
"maxStructFields": -1
}
}
debug test
功能不支持传入go.testFlags
,并且run test
功能不支持调试,所以只可以通过配置launch.json
文件,然后按F5
来进行单步调试。因为go test
是按照测试函数定义的顺序来执行的,所以,必须要在测试的时候调用t.Parallel()
来并发执行测试,然后在需要调试的测试函数处设置断点来进行调试。
主要是为golang
插件用的。
{
"debug.node.autoAttach": "on",
"go.vetOnSave": "package",
"editor.formatOnSave": true,
"go.lintOnSave": "package",
"go.buildTags": "",
"go.buildFlags": [],
"go.lintTool": "golint",
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.formatTool": "goimports",
"go.formatFlags": [],
}