Skip to content

Instantly share code, notes, and snippets.

@tupunco
Last active May 28, 2018 10:41
Show Gist options
  • Save tupunco/46ca49d91562003f3fbe751f3a2abb33 to your computer and use it in GitHub Desktop.
Save tupunco/46ca49d91562003f3fbe751f3a2abb33 to your computer and use it in GitHub Desktop.
vscode-go 开发环境配置[请访问新篇]

VSCode 开发配置

本篇内容有点陈旧, 请访问新篇 vscode-go 插件安装

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"
}
@abner-w
Copy link

abner-w commented Dec 5, 2017

@pengliheng 直接装一个Go插件, 然后调试的时候, 调试工具直接install all,装完就OK了。

@tupunco
Copy link
Author

tupunco commented Dec 27, 2017

@pengliheng 本篇内容过于陈旧, 请访问新篇 vscode-go 插件安装

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment