This guide covers various ways to debug the Go application.
- Go 1.24+ installed
- Delve debugger installed (automatically installed by the debug script)
- VS Code with Go extension (recommended for GUI debugging)
./debug.sh# Debug with main config
make debug
# Debug tests
make debug-tests# Debug main application
dlv debug main.go -- -config config.yaml
# Debug tests
dlv test ./... -- -v- Open the project in VS Code
- Install the Go extension if not already installed
- Press
F5or go to Run and Debug panel - Select one of the debug configurations:
- Debug Jira AI Issue Solver: Uses main config
- Debug Tests: Runs tests in debug mode
- Click in the left margin next to line numbers to set breakpoints
- Red dots indicate active breakpoints
# Set breakpoint at main function
(dlv) break main.main
# Set breakpoint at specific line in a file
(dlv) break main.go:75
# Set breakpoint in a specific package
(dlv) break services/jira.go:42
# Set breakpoint at function name
(dlv) break services.NewJiraService# Execution control
continue (c) # Continue execution
next (n) # Step over (execute current line)
step (s) # Step into (go into function calls)
stepout (so) # Step out (exit current function)
restart (r) # Restart program
# Breakpoints
break (b) # Set breakpoint
clear # Clear breakpoint
clearall # Clear all breakpoints
list # List breakpoints
# Variable inspection
print (p) # Print variable value
vars # Show variables in scope
locals # Show local variables
args # Show function arguments
# Stack and goroutines
bt # Show backtrace
goroutines # Show all goroutines
threads # Show threads
# Other
help (h) # Show help
quit (q) # Exit debugger- Use the Debug Console to evaluate expressions
- Hover over variables to see their values
- Use the Variables panel to inspect all variables
- Use the Call Stack to navigate through function calls
# Set breakpoint in Jira service initialization
(dlv) break services.NewJiraService
# Set breakpoint in Jira API calls
(dlv) break services.(*JiraServiceImpl).GetTicket
(dlv) break services.(*JiraServiceImpl).SearchTickets# Set breakpoint in GitHub service
(dlv) break services.NewGitHubService
# Set breakpoint in commit and PR operations
(dlv) break services.(*GitHubServiceImpl).CommitChanges
(dlv) break services.(*GitHubServiceImpl).CloneRepository# Set breakpoint in job execution
(dlv) break executor.(*Pipeline).Execute
# Set breakpoint in new-ticket pipeline
(dlv) break executor.(*Pipeline).executeNewTicket# Set breakpoint in work item scanner
(dlv) break scanner.(*WorkItemScanner).scan
# Set breakpoint in feedback scanner
(dlv) break scanner.(*FeedbackScanner).scan# Set breakpoint in job submission
(dlv) break jobmanager.(*Coordinator).Submit# Set breakpoint in config loading
(dlv) break models.LoadConfig# Print config after loading
(dlv) print config# Set breakpoint in health check handler
(dlv) break main.go:140# Show all goroutines
(dlv) goroutines
# Switch to specific goroutine
(dlv) goroutine 1- Check if config file exists and is valid
- Set breakpoint at
main()function - Check for fatal errors in config validation
- Set breakpoints in service initialization
- Check API tokens and URLs
- Monitor network requests
- Set breakpoints in executor pipeline (
executor.(*Pipeline).Execute) - Check container runtime logs (
podman logs <container-name>) - Verify AI API keys are configured and valid
- Check
guardrails.max_container_runtime_minutestimeout
- Use
goroutinescommand to see all running goroutines - Set breakpoints in scanner packages (
scanner.(*WorkItemScanner).scan) - Check for deadlocks in channel operations
# Run with CPU profiling
go run -cpuprofile=cpu.prof main.go -config config.yaml
# Analyze profile
go tool pprof cpu.prof# Run with memory profiling
go run -memprofile=mem.prof main.go -config config.yaml
# Analyze profile
go tool pprof mem.profThe application uses structured logging with Zap. You can:
- Set log level to
debugin config - Use JSON format for better parsing
- Monitor logs in real-time
logging:
level: debug
format: json- Start with main function: Set breakpoint at
main.mainto see program startup - Use conditional breakpoints: Set breakpoints that only trigger under specific conditions
- Monitor goroutines: Use
goroutinescommand to see concurrent operations - Check error handling: Set breakpoints in error handling code
- Use print statements: Combine debugging with strategic
fmt.Printfstatements - Profile performance: Use Go's built-in profiling tools for performance issues
# Reinstall Delve
go install github.com/go-delve/delve/cmd/dlv@latest
# Check Go version
go version- Ensure Go extension is installed and updated
- Check
go.modfile is in workspace root - Restart VS Code if needed
- Check Go tools are installed:
Ctrl+Shift+P→ "Go: Install/Update Tools"
# If you get permission errors with Delve
sudo sysctl -w kernel.yama.ptrace_scope=0