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

前端 未结 9 1142
予麋鹿
予麋鹿 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:50

    Another initiative for go debugging session: hopwatch

    Unlike most debuggers, hopwatch requires you to insert function calls at points of interest in your program. At these program locations, you can tell Hopwatch to display variable values and suspend the program (or goroutine).
    Hopwatch uses Websockets to exchange commands between your program and the debugger running in a HTML5 page.

    (so it is still similar to "print statement" but with a more elegant way to see the result without polluting stdout and stderr)

    hopwatch

    When your program calls the Break function, it sends debug information to the browser page and waits for user interaction.
    Using the functions Display, Printf or Dump (go-spew), you can log information on the browser page.
    On the hopwatch page, the developer can view debug information and choose to resume the execution of the program.

    with source

提交回复
热议问题