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
Perhaps some step by step instructions for getting started with GDB would help.
I created silly.go containing:
package main
import "fmt"
func x() {
foo := 5
fmt.Printf("foo: %v\n", foo)
}
func main() {
go x()
fmt.Printf("Done.\n")
}
After running 8g silly.go and 8l -o silly silly.8, I can run gdb silly. (I have "GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2" that as far as I know came with Ubuntu 11.04 32 bit.)
I can then type list, b 7 (short for break 7), and run. It stops at line 7, and I can run:
(gdb) p foo
$1 = 5
It would be interesting to see if the Eclipse/CDT debugger and/or DDD would work with Go.