VS Code Tips: Debugging in VS Code

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


VS Code has a powerful built-in debugger that works with many languages.

General Debugging

To start debugging:

  1. Click the Debug icon in the sidebar (or press F5)
  2. VS Code will prompt you to create a debug configuration if one doesn’t exist
  3. Set breakpoints by clicking in the gutter next to line numbers
  4. Start debugging

The debugger provides:

  • Variables inspection (local and global)
  • Watch expressions for specific variables
  • Call stack visualization
  • Breakpoints management

Debugging Go with Delve

For Go debugging, you need Delve.

Setup

  1. Install the official Go VS Code extension
  2. Make sure $GOPATH is configured
  3. On Linux/Windows: Run the command Go: Install/Update Tools
  4. On Mac: Install Delve via Homebrew:
brew install go-delve/delve/delve

Configuration

Press F5 to start debugging. VS Code creates a .vscode/launch.json file automatically:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${fileDirname}",
            "env": {},
            "args": [],
            "showLog": true
        }
    ]
}

Debug Modes

The mode parameter can be set to:

ModeDescription
debugCompile and debug the current program
testDebug tests (use -test.run and test name in args for single tests)
execRun a pre-built binary (specify path in program)
remoteDebug remotely

Tips

  • Step into library calls to learn how the standard library works
  • The Go standard library is well documented and readable
  • Debugging helps you understand internal workings of packages you use

Check the official documentation for more details and troubleshooting tips.

Lessons in this unit:

0: Introduction
1: Setup and Configuration Tips
2: Terminal Tips
3: Editing Tips
4: Prettier and Auto-Formatting
5: Language-Specific Settings
6: Emmet for Faster HTML/CSS
7: ▶︎ Debugging in VS Code
8: Fix node modules import errors in VS Code
9: Fixing TS issues in VS Code - Astro
10: regex select entire line starting with..