stackconf 2024 - IGNITE: Swiss knife for Go debugging with VSCode by Ivan Presenti.pdf

NETWAYS 7 views 20 slides Jul 25, 2024
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

Being able to debug your code in the IDE should be an easy process. If you ever struggled with debugging Go code in Visual Studio Code, this session is definitely for you. We’ll take a look at how to debug several kinds of projects by only tweaking settings in the dreaded “launch.json” file. Y...


Slide Content

@ossan
Swiss Knife for Go
Debugging with VSCode
Ivan ossan Pesenti
Software Developer
StackConf 2024
1

@ossan
Why Debugging?
Get more familiar with the codebase you’re working with. Follow the execution
path to find out functions invoked.
Find out where bugs happen and fix them. Allow you to slow down the code
execution in specific parts to dig into them.
Inspect variables’ values or complex objects and how they change while code
execution.
Codebase Knowledge
Detect Bugs
Inspection
2

@ossan
What Debugging?
01
0504
02
06
03
Unit Test
Functions.
Microservices-base
d apps.
Benchmark
Functions.
Integration Test
Functions.
Any piece of code
in your mind.
Command Line
Interface Apps.
3

@ossan
Delve in a Nutshell
●The debugger for Go programs
●Part of the Go tools
●Can be also installed outside of Visual Studio Code
●Listen to commands through a CLI tool
●Provide debugging capabilities outside of a regular IDE
4

@ossan
The “settings.json” File
●Home for all VS Code settings
●Every setting in User Preferences (GUI) can be found here
●Editor’s behavior, themes, extensions’ settings, keyboard shortcuts, etc.
●Boost developers productivity and consistency
●Allow to apply different settings based on the opened project (User VS Workspace)
5

@ossan
Go With the dlv-dap (not legacy)
6

@ossan
The “launch.json” File
7

@ossan
launch.json Configurations
●Selectable in Run View menu
●Holds a specific configuration
to test, debug, launch, etc. a
specific piece of code
●Different for each scenario
●Prepares the input for Delve
8

@ossan
Debug Unit Test
9

@ossan
Debug Integration Test
10

@ossan
Debug
Integration Test
11

@ossan
Attach to Process
12

@ossan
Attach to Process
13

@ossan
Compound Configuration
14

@ossan
Compound Configuration
15

@ossan 16

@ossan
Debug StdIn
17

@ossan
Global Variables
18

@ossan
Debug Console Evaluation
19

@ossan
Thanks
05
20
t.ly/pDNHV
QR code and Link to the repository