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

从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 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据