ctrl+shift+p
安装
vscode-go
插件:> ext install Go
安装
go tools
:> Go Install/Update Tools
新项目按
vscode-go-build
配置.下载失败配置
hosts
:https://github.com/racaljk/hosts
VSCode 开发配置
settings.json
VSCode 工作区配置. 菜单 文件->个性化配置->工作区设置
来触发本配置.GOPATH
多个路径在 Mac
下需要 :
分割, Windows
下需要 ;
分割, 下面涉及到的 GOPATH
都遵循此规则.
本节点配置后需要重启
VSCode 来生效.
{
"go.gopath": "G:\\Work\\GoPath;G:\\Work\\SVN\\...自定义目录...\\"
}
launch.json
调试运行配置. 主要配置 ENV
节点 GOPATH
项. F5
触发本配置.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
// "mode": "exec",
// "program": "${workspaceRoot}/...自定义目录....exe",
"mode": "debug",
"program": "${workspaceRoot}",
"env": {
"GOPATH":"G:\\Work\\GoPath;G:\\Work\\SVN\\...自定义目录...\\"
},
"args": []
}
]
}
tasks.json
快捷键 Ctrl + Shift + B
来触发 配置新任务
, 选择 其他
任务. 平时使用也用此快捷键查看 Build
情况.
不同系统自行配制不同节点.
{
"version": "0.1.0",
"command": "go",
"isShellCommand": true,
"args": [
"build",
"-i",
"-v"
],
"windows": {
"options": {
"env": {
"GOPATH": "G:\\Work\\GoPath;G:\\Work\\SVN\\...自定义目录...\\"
}
}
},
"linux": {
"options": {
"env": {
//"GOPATH": "/home/USERNAME/GoPath:/home/USERNAME/Work/Git/...自定义目录.../"
}
}
},
"osx": {
"options": {
"env": {
//"GOPATH": "/home/USERNAME/GoPath:/home/USERNAME/Work/Git/...自定义目录.../"
}
}
},
"showOutput": "always"
}
所有配置文件在 .vscode 文件夹下
settings.json
自定义 GOPATH 配置:
本配置不是必须, 碰到独立 gopath 项目设置.
{
"go.gopath": "${workspaceRoot}"
}
task.json
快捷键 Ctrl+Shift+b
触发 手动编译任务
, 首次调用会自动创建 task.json
:
linux/osx run 命令没有测试是否正确
{
"version": "0.1.0",
"command": "go",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [{
"taskName": "build",
"isBuildCommand": true,
"args": [
"-i",
"-v"
]
}
],
"showOutput": "always",
"windows": {
"tasks": [
{
"args": [
"build",
"&",
"${workspaceRootFolderName}.exe"
],
"taskName": "run"
}
],
"options": {
"env": {
"GOPATH": "${env.GOPATH};${workspaceRoot}"
}
}
},
"linux": {
"tasks": [
{
"args": [
"build",
"|",
"./${workspaceRootFolderName}"
],
"taskName": "run"
}
],
"options": {
"env": {
"GOPATH": "${env.GOPATH}:${workspaceRoot}"
}
}
},
"osx": {
"tasks": [
{
"args": [
"build",
"|",
"./${workspaceRootFolderName}"
],
"taskName": "run"
}
],
"options": {
"env": {
"GOPATH": "${env.GOPATH}:${workspaceRoot}"
}
}
}
}
launch.json
配置调试:
{
"version": "0.2.0",
"configurations": [{
"name": "dlv-DEBUG",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}",
"windows": {
"env": {
"GOPATH": "${env.GOPATH};${workspaceRoot}"
}
},
"linux": {
"env": {
"GOPATH": "${env.GOPATH}:${workspaceRoot}"
}
},
"osx": {
"env": {
"GOPATH": "${env.GOPATH}:${workspaceRoot}"
}
},
"args": []
}]
}
keybindings.json
快捷键配置:
ctrl+shift+delete
强制结结束执行任务,ctrl+r
运行task.json
内配置的任务
[
{
"key": "ctrl+shift+delete",
"command": "workbench.action.tasks.terminate"
},
{
"key": "ctrl+r",
"command": "workbench.action.tasks.runTask",
"when": "editorTextFocus"
}
]
ft_authoradmin ft_create_time2017-08-18 10:44
ft_update_time2017-10-29 14:42
ft_update_time2017-10-29 14:42