Peek-A-Go traces a Go program step by step with headless Delve and prints a JSON execution trace.
The goal is to make Go execution easier to inspect and eventually support visualizations similar to Python Tutor.
- Accepts a single Go source file containing a runnable
package main - Writes the source into a temporary module
- Starts
dlv debugin headless mode - Steps through execution and captures:
- source line
- local variables
- package-level variables
- Prints the collected trace as formatted JSON
- Go
- Delve (
dlv) available onPATH
Run directly:
go run . path/to/program.goShow help:
go run . -hBuild a binary:
go build -o peek-a-go .
./peek-a-go path/to/program.goThe CLI prints a JSON array of steps like:
[
{
"File": "main.go",
"Line": 5,
"Function": "",
"Locals": {
"x": "2"
},
"Globals": {
"total": "3"
}
}
]The test suite uses fixture programs under testdata/progs.
Run tests with:
go test ./...- The current implementation traces a single linear execution timeline.
- It is intended for small runnable programs.
- The trace format is designed for downstream visualization tools.