Debugging Go App on VS Code using Delve Debugger

Background

santosh
2 min readApr 27, 2024

We are using Go lang for few of our project and we struggled in debugging application using open source/free tools.
And finally succeeded using delve + go + vs-code

Tools we will be using
- VS-Code
- delve
- Mac Book M2

Step1: Installing delve

Installation is pretty straightforward as listed below

$ git clone https://github.com/go-delve/delve
$ cd delve
$ go install github.com/go-delve/delve/cmd/dlv

And follow steps outlined here

Step2: Verifying installation

Step3: Creating launch json

To create a launch.json file, select create a launch.json file in the Run start view

fig2: launch.json
fig3: launch.json

Step4: Providing parameter to the project

Most of the enterprises application will have good amount of parameters to start the application.
What we can do is create a XXX.env file and provide that location in launch.json using envFile tag.

Step5: Running the application

Go to menu Run -> Start Debugging to start the debug session below pop up will appear allow and debug the application.

Happy Debugging Go app.

Photo by Austin Schmid on Unsplash

Sign up to discover human stories that deepen your understanding of the world.

--

--

santosh
santosh

No responses yet

Write a response