How do I debug a program written in the Go language?

前端 未结 9 1350
予麋鹿
予麋鹿 2021-02-02 06:17

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

9条回答
  •  没有蜡笔的小新
    2021-02-02 07:02

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

提交回复
热议问题