golang debug with LiteIDE

golang 的调试比较麻烦,debug stop into 无法跳转到自己写的代码,但是能够跳转到系统提供的代码。

以下是简单的测试代码:

package main

import (
"fmt"
)

func main() {
i := 5
even(i)
b := 1
fmt.Printf("Is %d even? %v\n", i, b)
}

func even(i int) bool {
a := 1
b := a + 1
b = b + 1
return i%2 == 0
}

这个情况太诡异了,网上到处是对golang gdb的吐槽。详情可以看这里:

http://grokbase.com/t/gg/golang-nuts/1443r0vch8/go-nuts-debugging-in-go-seems-to-be-a-very-difficult-task-to-accomplish

不过好在最后有人提供了LiteIDE里面设置的方式。

1 - Open your project in LiteIDE2 - Select "Build" menu and under it select "Build Configuration..."3 - A dialog shows up. Select "Custom" tab. It contains a list of key/valuepairs4 - Double click the space reserved for the value of "BUILDARGS"5 - write -gcflags "-N -l"6 - close the dialog by clicking Ok button7 - rebuild your project (Ctrl+B)8 - press F5 to start debugging9 - put some breakpoints wherever you wish10 - press f5 again to reach the first breakpoint

解决方案:

1 - 打开LiteIDE Build设置2 - 修改BUILDARGS 变量,添加参数 -gcflags "-N -l" 注意这里有引号3 - 保存后即可4 - enjoy it
上一篇:LeetCode149:Max Points on a Line


下一篇:手机端 H5上传头像