douci2015 2018-07-31 14:24
浏览 886
已采纳

从GoLand Terminal运行时如何调试

Is possible to debug from terminal (included in GoLand IDE), what I want to do is to stop in a break point when you run a .go file from the terminal. This because I want to run the script sending parameters to go to validate if parameters has been received to the .go script.

GoLand Breakpoint

GoLand Terminal

Thanks.

  • 写回答

3条回答 默认 最新

  • doushijiao0679 2018-07-31 14:45
    关注

    Yes, it's possible to debug from GoLand! For me next approach is the best:

    1) For example we have x.go:

    package main
    
    import "fmt"
    
    func main() {
        name, ending := "World", "!"
        ending2 := `)`
        fmt.Printf("Hello %s %s%s 
    ", name, ending, ending2)
    }
    

    2) Edit your debug configuration:

    enter image description here

    3) Run in console next command:

    go build -gcflags='-N -l' x.go \
        && dlv --listen=:2345 --headless=true --api-version=2 exec ./x
    

    4) Now place your breakpoint and hit "debug" button.

    Here you can find video how it looks for me.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图