Description
Course info
Level
Intermediate
Updated
Jul 10, 2017
Duration
2h 5m
Description

When Go was first released in 2012, there were limited options for debugging Go code. Most debugging work was handled by the open-sourced debugger "GDB". While this tool provided some help, it was not designed to work with several important Go language features – most notably goroutines. There have been several attempts to address the lack of a native debugger over the years. Eventually, Derek Parker's Delve tool took the lead and is now one of the most common tools for debugging Go applications. In this course, Debugging Go Applications with Delve, you'll take a deep dive into the Delve debugger and learn how to work with it to fully understand and analyze bugs that creep up in a Go application. First, you'll explore and manipulate an application's state during a debugging session. Next, you'll learn how to use breakpoints, conditional breakpoints, and tracepoints. Then, you'll discover the numerous ways that Delve can start a debugging session. Finally, you'll learn how to access Delve from a code editor. By the end of this course, you'll know how to use Delve from the command line as well as how to access it from your favorite editor.

About the author
About the author

Michael Van Sickle is an application architect in Akron, Ohio. He is a mechanical engineer by training and a software engineer by choice. He is passionate about learning new programming languages and user experience design.

More from the author
The Go CLI Playbook
Intermediate
2h 8m
28 Feb 2018
Intern 4: Getting Started
Beginner
2h 41m
9 Jan 2018
Object-oriented Programming with Go
Intermediate
1h 42m
11 Aug 2017
More courses by Mike Van Sickle
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name is Michael Van Sickle, and welcome to my course, Debugging Go Applications with Delve. When Go was first released in 2012, there were limited options for debugging Go code. Most debugging work was handled by the open source debugger GDB. While this tool provided some help, it was not designed to work with several important Go language features, most notably goroutine. Derek Parker's Delve has taken the lead and is now one of the most common tools for debugging Go applications. In this course, we're going to take a deep dive into the Delve tool and learn how it can help us debug our Go code. Some of the major topics that we will cover include, how to explore and manipulate an application state during a debugging session, how to use breakpoints, conditional breakpoints, and tracepoints, the numerous ways that Delve can start a debugging session, and how to access Delve from a code editor. By the end of the course, you'll know how to use Delve from the command line, as well as how to access it from your favorite editor. Before beginning the course, you should be familiar with the Go language. I hope you'll join me on this journey to learn Delve with the Debugging Go Applications with Delve course, at Pluralsight.

Introduction
Hello, and welcome to this course where we are going to learn how to debug Go applications using the Delve tool. A couple of years ago when I was first starting to offer courses for Pluralsight, someone asked me to show them how to debug their Go applications. They believe, and I agree, that it is a fundamental skill for learning how to work in a new language. Unfortunately, Go didn't have a good debugging tool at the time, so I had to disappoint him. Well today I'm happy to say that Go now has a first-class debugger called Delve, and that's what we're here to talk about. I want to start this conversation by talking about what it is to debug in Go and what the options have been over time, and where Delve fits in that picture. Then we'll introduce the Delve tool itself, giving you a little bit of background about it, as well as an overview of some of the features that it contains. Then we'll go through the installation and usage of the tool to get you started and get you your first taste for what it's like to debug applications using Delve. Okay, so let's get started by talking about the options that we have for debugging our Go applications.

Exploring Application State
Hello, and welcome back. In the last module, we got introduced to Delve and saw our first demonstration of how to work with it. In this module, we're going to dive deep into the commands that Delve offers us when we need to inspect and manipulate an application as it's being run. Now we're going to divide this conversation up into three basic groups. The first conversation we're going to have is on the general commands, and these are the general commands that you're going to be using anytime you use Delve. So we're going to be talking about how to get some help, how to quit out of the debugger, and things like that in this section. Then we'll talk about the commands that Delve exposes to allow us to inspect the state of our application. And finally, we'll see the commands that are available to allow us to manipulate the application as it's being run. Okay, so let's get started and learn some general commands that we can use with Delve.

Using Breakpoints
Hello, and welcome back. In the last module, we talked about how to inspect and manipulate the state of an application at a given point in its execution. In this module, we're going to learn how to stop executing the program in places that we specify, and we'll also learn how to continue from those breakpoints. So this discussion naturally breaks down into two separate topics. We'll talk about the means and the commands that are available to us to stop the execution of our program, and then we'll finish up our discussion by learning how to get our application restarted after we've stopped it. Okay, so let's get started by learning how we can stop our application's execution.

Delve Commands
At this point in the course, you've seen all of the commands that Delve offers us to inspect, manipulate, and walk through an application's execution. Now it's time to take a look at the options that Delve offers us to start a debugging session. We'll do that by exploring the Delve command and its various options. So we're going to start this discussion with the Delve command itself. So just running the dlv command offers us quite a few options that are available to every subcommand that Delve exposes. So we're going to take a few minutes, and we're going to talk about those options and what they can do for us. Then we'll talk about the various subcommands that Delve exposes to allow us to start an application. Now we've been using the delve debug command to start our applications, so we're going to see that one introduced formally, and then we're going to see a couple of other options that are available. Then we're going to see how we can use Delve to attach to a running process. So as you can imagine, if you've got a web application running in production or some sort of a web service, you might not be able to pull that application down to start a debugging session. So we're going to see how we can actually ask Delve to attach to that process so that we can inspect it, do some debugging on the process, and then exit out, potentially even leaving the process running after we're done with it. And then finally, we're going to talk about a couple of commands that Delve offers us to do post-mortem analysis. So if you have an issue with your application and you get a core dump out, we're going to see how you can use Delve to actually inspect that core dump, and see what happened to hopefully prevent a reoccurrence of that. Okay, so no slides coming up here, we're going to dive right into a demo and start talking about the dlv command.

Editor Integration
At this point, we've covered all of the things that Delve can do for us. However, we've been focused strictly on how to use Delve from the command line. While this gives us the highest level of flexibility and power, many of you might prefer to work with Delve without having to leave your code editor, or you might prefer to use a graphical user interface. In this module, we'll talk about your options in those areas. We'll start by talking about the different editor integrations that Delve offers us, and then we'll move into a discussion of an alternative UI that's available to get the full power of Delve, but through a graphical user interface instead of from the command line. Okay, so let's dive in and start talking about the editors that currently support Delve.