step 1

下载Visual Studio Code并安装,下载地址:

https://www.visualstudio.com/en-us/products/code-vs.aspx

最新版本是0.10.1,这个版本微软正式支持了插件机制,可以预见的将来,就是sublime的死期。

step 2

安装各种go tool,因为大多数go tool都会从golang.org获取内容,所以请翻墙:

go get -u -v github.com/nsf/gocode  
go get -u -v github.com/rogpeppe/godef  
go get -u -v github.com/golang/lint/golint  
go get -u -v github.com/lukehoban/go-find-references  
go get -u -v github.com/lukehoban/go-outline  
go get -u -v sourcegraph.com/sqs/goreturns  
go get -u -v golang.org/x/tools/cmd/gorename  

step 3

打开vs code,同时按command + shift + p,输入extension install,找到go插件,现在最新的版本是0.6.10。

step 4

获取调试器delve的源码:

https://github.com/derekparker/delve.git  

如果你的系统是linux,那么只要进入代码目录make install即可。

如果你是mac os,那么要麻烦一些:

制作一个自签名的钥匙串

Open application “Keychain Access” (/Applications/Utilities/Keychain Access.app)  
Open menu /Keychain Access/Certificate Assistant/Create a Certificate...  
Choose a name (dlv-cert in the example), set “Identity Type” to “Self Signed Root”, set “Certificate Type” to “Code Signing” and select the “Let me override defaults”. Click “Continue”. You might want to extend the predefined 365 days period to 3650 days.  
Click several times on “Continue” until you get to the “Specify a Location For The Certificate” screen, then set “Keychain to System”.  
If you can't store the certificate in the “System” keychain, create it in the “login” keychain, then export it. You can then import it into the “System” keychain.  
In keychains select “System”, and you should find your new certificate. Use the context menu for the certificate, select “Get Info”, open the “Trust” item, and set “Code Signing” to “Always Trust”.  
[At least on Yosemite:] In keychains select category Keys -> dlv-cert -> right click -> GetInfo -> Access Control -> select "Allow all applications to access this item" -> Save Changes.
You must quit “Keychain Access” application in order to use the certificate and restart “taskgated” service by killing the current running “taskgated” process. Alternatively you can restart your computer.  
Run the following: CERT=dlv-cert make install, which will install the binary and codesign it.  

中文版:

1. 菜单->钥匙串访问->证书助理->创建证书  
证书名填dlv-cert,之后勾选[让我覆盖这些值]
2. 把365天改成3650  
3. 之后一路continue,直到选择请指定钥匙串以便保存证书  
选择[系统]
4. 点击创建完成  
5. 在钥匙串管理里搜索刚才创建的证书,双击,修改代码签名选项为始终信任  
6. 再到到dlv-cert的两个密钥,如果可以的话,选择访问控制,然后选择最大权限(在我的EL Capitan系统里这个选项始终改不了,不知道为什么),输入管理员用户名密码,完毕。  

完成上述步骤后:

$ CERT=mycert make install

之后打开vscode,打开你的项目,打上断点,之后再在左边的debug栏点击运行(可能需要输入密码),之后就可以看到断点处的变量值、函数调用栈等调试信息了。