This lesson is locked. Login or Subscribe for more access!

Setting up the debugger in VSCode

Duration: 3 mins

In this lesson we'll get you read to debug in VSCode.

Instructor

Matt Boyle

Share with a friend!

Transcript

Hey folks, in this video we're going to make sure you can get the debugger running in Visual Studio Code as well. And we start with a completely clean install. It's not too difficult to get set up, but there are a couple more steps than if you're using Goland.

So firstly, you can see I've just opened Google and I've searched for Visual Studio Code. We're going to head to this link and download this. Once it's downloaded, we just need to click on the binary, and you can see mine is opening here.

And we now have Visual Studio Code open. I've opened the ultimate debugging logging module that I shared previously. I'm just going to make sure we can get the debugger running here. The first thing we're going to do is we need to go and install the debugging tools. To do that we need to add to this link which I shared in the video description.

And as you can see, this installs Go, and it's from the Go team at Google. It's been verified to be from Go.dev. So if you click this, it's going to open the extension in Go. It looks like I've still got the extension installed, even though I uninstalled VS Code.

So what you may see when you do this is at the bottom right corner here, it might say something like "dependencies missing" or "some tooling missing". If you click that, it'll say we need to install Go PLS and some other things to get the debugger running. If you just click on it and press install, it should install a couple more Go tools if you haven't got them already. It looks like I already have them, so it hasn't done it.

This should be everything you need to start debugging. So to prove it, what we're going to do is we're just going to go to main.go in either the logging module, if you've still got it set up, or just any Go program you've got. And effectively, I just want you to click in the left-hand side gutter here until it goes bright red like this. This is called a breakpoint. We'll talk about this a little bit more in a moment in a different video of the course.

But once you've hit that breakpoint if you go to run and put start debugging and it comes up with this window here and as you can see my program has paused here which is exactly what we want and it proves that the debugger works. If you want to you can use this button and it's just going to step over and now we can step through our program methodically.

So once you get to this stage this is all we want to do for this video. This proves you've got Go set up on your machine, you've got Visual Studio Code installed and the debugging tools are going to work for you. So I hope this was helpful and I'll see you in the next video.