Skip to main content

Local debugging guide — Go

Last updated on May 25, 2026

This guide covers everything specific to debugging an Extend Service Extension app written in Go. For general debugging concepts — environment setup, VS Code debug workflow, log reading, and common issues — see:


Project structure​

File / PackageWhat it does
main.goEntry point — wires together gRPC server, gRPC-Gateway, metrics, tracing, and auth.
pkg/service/myService.goYour business logic — implements the gRPC service methods.
pkg/storage/storage.goTalks to AccelByte CloudSave to persist and retrieve data.
pkg/common/authServerInterceptor.goValidates every incoming request's IAM token and permission.
pkg/common/logging.goBridges the gRPC middleware logger to Go's slog.
pkg/common/tracerProvider.goSets up OpenTelemetry distributed tracing (Zipkin exporter).
pkg/proto/service.protoDefines the gRPC API — endpoints, request/response shapes, and required permissions.
pkg/pb/Auto-generated Go code from .proto. Do not edit directly.

Port numbers (constants in main.go):

PortPurpose
6565gRPC server (internal — used by gRPC-Gateway)
8000gRPC-Gateway HTTP/REST — call this from a browser, Postman, or curl
8080Prometheus metrics endpoint (/metrics)

Running the service locally​

From the terminal​

# Export all variables from your .env file
export $(grep -v '^#' .env | xargs)

go run main.go

From VS Code​

Use Terminal → Run Task → "Run: Service". This task is defined in .vscode/tasks.json and prompts you for BASE_PATH if it is not already set.

Confirming the service is up​

You should see logs like:

{"time":"...","level":"INFO","msg":"app server started","service":"extend-app-service-extension"}
{"time":"...","level":"INFO","msg":"starting gRPC-Gateway HTTP server","port":8000}
{"time":"...","level":"INFO","msg":"serving prometheus metrics","port":8080,"endpoint":"/metrics"}

Open http://localhost:8000<BASE_PATH>/apidocs/ in your browser to verify Swagger UI is live.


Attaching the debugger​

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"
}

Follow the attaching the debugger steps in the generic guide, then select "Debug: Service" from the dropdown.

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).


Where to put breakpoints​

What you want to investigateFile and location
A specific REST endpoint being calledpkg/service/myService.go — top of the relevant method
Auth/token validation failurepkg/common/authServerInterceptor.go — NewUnaryAuthServerIntercept
Data not saving or loading correctlypkg/storage/storage.go — SaveGuildProgress / GetGuildProgress
Service not starting at allmain.go — just before os.Exit(1) calls

For conditional breakpoint syntax, see the Go language guide.


Reading logs​

For jq log filtering, see the Go language guide.


Testing endpoints manually​

For curl and grpcurl usage, see Testing with grpcurl in the generic guide.

For Swagger UI testing (SE-specific), see Testing endpoints manually in the SE main guide.


Go-specific troubleshooting​

Proto changes have no effect​

Symptom: You edited pkg/proto/service.proto but nothing changed at runtime.

Cause: The generated stubs in pkg/pb/ have not been regenerated.

Fix: Run the "Proto: Generate" VS Code task, or:

./proto.sh

Then restart the service.


go run vs the debugger launch config​

go run main.go compiles without debug information. When you need to attach a debugger, always use the VS Code launch config (or dlv debug) rather than go run.


Checking for port conflicts​

See Checking for port conflicts in the Go language guide.


AI assistance​

The app template ships with a Claude agent skill at .claude/skills/debugging-guide/SKILL.md.

For AI prompting tips and MCP server details, see Debugging with AI assistance in the generic guide.


References​