Tag: line number exists launch log. JSON SCI exits GES Bre
This article contains the following content:
1. Install Vscode;
2. Debug the Go project with delve;
3. custom code Snippets;
1. Installing Vscode
To download Vscode, there are also official documents in this link.
To install the plugin:
Vscode-icons This plugin allows Vscode to display the file icon, making it easier to identify complex files within the project,
Attention:
When you open a Go project with Vscode, open the directory where the project is located,
That is the standard/BIN/PKG/SRC, the directory where the three folders are located,
Instead of opening a specific. go file, otherwise the code auto-complete function will be abnormal!
2. Debug the Go project with delve
Install delve, recommend Brew install Go-delve/delve/delve, do not have to configure a lot of troublesome things.
If encounter error, should be /usr/local existence permission problem , sudo chmod-r 777/usr/local.
Start debugging within the Vscode open Go project file: Debug-Start Debugging (F5),
No surprises, you should see an error prompt to open the Launch.json file:
name random configuration;
Port as long as not commonly used ports, there should be no conflict, arbitrary configuration;
program configures the Go Project startup file path, which is the path to the . Go file where the main function resides.
${workspaceroot} represents the root directory of the project,
This is the directory where the three folders of /bin/pkg/src are located;
env can be used to configure the environment variable parameters that are used when debugging starts.
For example, Gopath is temporarily set to a parameter can be specified here,
If there are multiple Gopath, use a colon: to connect multiple Gopath;
Trace can print the log executed by Delve , and the log directory will be output in the console,
Press Start debugging again and you can see the debug console output:
The top of the Vscode also appears, and it is recommended to use the shortcut keys:
To add a breakpoint can be left click the left mouse button on the line number, a small red dot, click again to cancel the breakpoint:
If you fail to perform debugging, you can view the information in the logs file under the Trace option record mentioned above.
Open the log file to see some information Delve printing:
You can see the directory where the Delve program resides, as well as the return code when the program main process runs out.
(Bo Master in the installation of delve when the detour, so this machine has two delve,
It was not installed with homebrew, the keychain was not configured properly.
So, by looking at this log only to find that the debugging is not installed through homebrew,
Then immediately delete the problematic DLV, start debugging again, problem solving! )
3. Custom code Snippets
Select Menu: Code-Preferences-user code snippet , pop-up list click Go, will enter into the go.json file,
Then follow the example to edit it.
For example, I define defer closures, which are formatted using ASCII notation (\ n, \ t , and so on):
In Vscode open the. Go file, enter Fdefer, and you will see:
Then enter, you will see the cursor at 1 position, press TAB will jump to 2:
Enjoy the joy that Vscode brings to you!
Ficow Original, reproduced please specify the source:http://www.cnblogs.com/ficow/p/6785905.htm
Golang on Mac with Vscode development, delve debugging