How do I debug a Go program? I have been using the Gedit Go IDE, but it doesn\'t have debugging. Is there a way to step though my code and inspect memory? Or am I stuck with
There is an experimental debugger package called ogle. Not sure how well it works.
GDB 7.5 officially supports Go.
Another debug technique being developed (Q4 2014): Go Execution Tracer
The trace contains
- events related to goroutine scheduling:
- a goroutine starts executing on a processor,
- a goroutine blocks on a synchronization primitive,
- a goroutine creates or unblocks another goroutine;
- network-related events:
- a goroutine blocks on network IO,
- a goroutine is unblocked on network IO;
- syscalls-related events:
- a goroutine enters into syscall,
- a goroutine returns from syscall;
- garbage-collector-related events:
- GC start/stop,
- concurrent sweep start/stop; and
- user events.
By "processor" I mean a logical processor, unit of
GOMAXPROCS
.
Each event contains event id, a precise timestamp, OS thread id, processor id, goroutine id, stack trace and other relevant information (e.g. unblocked goroutine id).