Swiss knife for Go debugging with VSCode

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. You'll discover how many options and customizations you can apply to this file to leverage your debugging experience. Finally, we briefly touch on the key features of the Delve debugger.

LEVEL: Introductory and Overview

Place
GoLab Discovery
Length
25 min
When
November 13th, 2024
14:30

Abstract

DESCRIPTION:

One of the most important things when we're writing code is the ability to debug it. Many IDEs have an integrated debugger that can smoothen our coding experience. The debugger for the Go source code is called Delve. It's tightly integrated with VSCode and the Go extension. As you might know, the debugger allows us to step through our code, focus on specific sections that may deserve more attention, inspect variables' values, stack traces, etc.
Sometimes, debugging turns into a hassle. The process supposed to help us becomes an insurmountable obstacle. Sometimes, we abandon the debugging or log directly into the code. Both of the options end up decreasing our productivity as developers.

Thus, this talk aims to provide a working solution to debug Go code in VSCode. I chose this IDE since it's free, highly customizable, performant, and my favorite!
Since we can build different projects, I try to provide you with a working solution for each. The scenarios you're likely to face are (list not exhaustive):

- Debug unit tests
- Debug integration tests
- Debug a package
- Attach to an already running process (both locally and remotely)
- Debug multiple microservices with the compound configuration

To overcome these challenges, you're requested to tweak settings in the `launch.json` file within the hidden .vscode folder. In this file are listed what are known as profiles. These are selectable in the "Run View" area. Within this file, we have the option to set different values, such as:

- environment variables or env file
- whether to show global variables' values
- which console to use
- and many others

Throughout this talk, I share hints on Delve and how to make the most of it. I also touch on some overlooked aspects of VSCode that can make a huge difference in your debugging experience.
Finally, I'll give you some mind-blowing tips and tricks on debugging. If you'd like to improve your debugging skills, please don't miss my session!

GoLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".


Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2024 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS