首先安装ssh,可以连接Linux虚拟机
在vscode商店点击安装C/C++相关的
在左侧栏点击齿轮的按钮,表示调试
修改文件路径
添加task.json
修改为
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": ["-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
启动调试
参考
https://code.visualstudio.com/docs/cpp/config-linux
golang类似
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": "${workspaceFolder}/chat/server/main.go",
"env": {"GOPATH":"/root/go","GOCACHE":"/root/.cache/go-build"},
"args": [],
"showLog": true
}
]
}
task.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "/usr/local/go/bin/go"
}
]
}