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

前端 未结 9 1110
予麋鹿
予麋鹿 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 06:56

    There is an experimental debugger package called ogle. Not sure how well it works.

    0 讨论(0)
  • 2021-02-02 06:57

    GDB 7.5 officially supports Go.

    0 讨论(0)
  • 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).

    0 讨论(0)
提交回复
热议问题