0. Overview

Introduces the general Linux environment installation method of VSCode and the process of configuring a Go developer environment.

1. Installation

1.1. Download the executable file

Open the official website and download the corresponding tarball: download address

1.2. Unzip the executable file

  1. [root@liqiang.io]# tar -zxvf code-stable-x64-1602601238.tar.gz -C /opt/
  2. [root@liqiang.io]# chmod +x /opt/VSCode-linux-x64/code
  3. [root@liqiang.io]# ln -s /opt/VSCode-linux-x64/code /usr/local/bin/code

1.3. Start vscode

  1. [root@liqiang.io]# code
Figure 1:vscode open page

2. Configure Remote Developer

2.1. Install client plugin

Using:Ctrl + Shift + P open command tool,and execute following two commands:

  1. [root@liqiang.io]# ext install ms-vscode-remote.vscode-remote-extensionpack
  2. [root@liqiang.io]# ext install ms-vscode-remote.vscode-remote-extensionpack

2.2. Install server plugin

VSCode A variety of remote tools are supported, I chose the SSH method, in addition to SSH there are:

Assume here that my remote machine is:10.0.63.154

  1. [root@liqiang.io]# ssh-copy-id root@10.0.63.154 # Configure loginwith password

2.3. Connect remote machine

3. Install Go Develop Environment

3.1 Install Go Plugin

Using shortcut Ctrl + Shift + X to open the plugin page,and search Go plugin,then click install:

Figure 2:Install Go lang plugin

3.2 Install Go Tools

Open the command tools windows by shortcut Ctrl + Shift + P,Search “Go: Install/Update Tools”

Figure 3:Install Go Tools

And then select all,Click “OK” and then install:

Figure 4:Choose Go Tools

4. Debug Go Application by dlv

Now you can start configuring the Go debugging tools.

4.1 Configure file

Open the debugging tool via the shortcut key Ctrl + Shift + D and find the link inside:

Figure 5:Add debug configure

If you can’t find it,you can also open the .vscode directory below the root directory,and create a new file named:launch.json,wirte the following content into the file:

  1. [root@liqiang.io]# cat .vscode/launch.json
  2. {
  3. "version": "0.2.0",
  4. "configurations": [
  5. {
  6. "name": "Launch",
  7. "type": "go",
  8. "request": "launch",
  9. "mode": "auto",
  10. "program": "${workspaceFolder}/apps/main.go",
  11. "env": {
  12. "env":"test"
  13. },
  14. "": "envFile\": \"${workspaceFolder}/.env",
  15. "args": []
  16. }
  17. ]
  18. }

Now, you have finish your configure。

4.2 Add breakpoint

It’s so easy to add the breakpoint,just click you mouse near the code line:

Figure 6:Add breakpoint

4.3 Begin debug

You can start to debug you code via shortcut F5,and can also open the debug window and click Run button to debug:

Figure 7:Debug Code

Then, after stopping at the breakpoint, you can choose whether to step or skip:

Figure 8:Debug method

5. Frequent shortcuts

5.1 Direct shortcut

5.2 Shortcut plugins

Figure 9:Autofill struct fields