Skip to main content

Local debugging — Go

Last updated on April 8, 2026

This guide covers everything specific to debugging an Extend app written in Go. For concepts that apply to all Extend apps and languages — environment variables, VS Code debug workflow, log reading, and common issues — see the Extend local debugging guide.


Prerequisites

  • Go 1.24 or later — verify with:

    go version
    # Expected: go version go1.24.x ...
  • VS Code Go extension (golang.go) — install from the VS Code marketplace or accept the recommended extensions prompt when you open the repository.

  • Delve (Go debugger) — the Go VS Code extension installs Delve automatically. Verify with:

    dlv version
  • AccelByte credentialsAB_BASE_URL, AB_CLIENT_ID, AB_CLIENT_SECRET. See Environment setup in the main guide.


VS Code launch configuration

The repository ships with a ready-to-use launch configuration in .vscode/launch.json:

{
"name": "Debug: Service",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"envFile": "${workspaceFolder}/.env",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal"
}

Steps:

  1. Fill in .env (see Environment setup).
  2. Open the Run and Debug panel (Ctrl+Shift+D / Cmd+Shift+D).
  3. Select "Debug: Service" from the dropdown.
  4. Press F5.

The Go extension uses Delve under the hood. You do not need to configure it separately.


Other IDEs — Delve headless mode

Start Delve in headless mode so your IDE can connect to it:

dlv debug --headless --listen=:2345 --api-version=2 .

Then configure your IDE to attach to localhost:2345 via DAP (Debug Adapter Protocol).


Conditional breakpoint syntax

Right-click a breakpoint → Edit Breakpoint → enter a Go expression. Example:

req.UserId == "user_001"

The debugger only pauses when the condition is true.


Reading logs with jq

# Pretty-print everything
go run main.go 2>&1 | jq '.'

# Show only ERROR lines
go run main.go 2>&1 | jq 'select(.level == "ERROR")'

For an overview of the log format and log levels, see Reading and understanding logs in the main guide.


Go-specific troubleshooting

go run vs the debugger launch config

go run main.go compiles without debug information. When you need a breakpoint to pause execution, always use the VS Code launch config (which invokes Delve) rather than go run.

Checking for port conflicts

ss -tlnp | grep -E '6565|8000|8080'

Kill the stale process and start again.


References