一、安装 参考文档 https://github.com/go-delve/delve/blob/master/Documentation/installation/linux/install.md
二、使用
- go build hello.go 生成二进制文件 hello
dlv exec ./hello -- server --config conf/config.toml
break main.go:52
(dlv) break main.go:52
Breakpoint 1 set at 0x109b901 for main.main() ./main.go:52
(dlv) bp
Breakpoint runtime-fatal-throw at 0x1028450 for runtime.fatalthrow() /usr/local/go/src/runtime/panic.go:663 (0)
Breakpoint unrecovered-panic at 0x10284c0 for runtime.fatalpanic() /usr/local/go/src/runtime/panic.go:690 (0)
print runtime.curg._panic.arg
Breakpoint 1 at 0x109b901 for main.main() ./main.go:52 (0)
(dlv) c
> main.main() ./main.go:52 (hits goroutine(1):1 total:1) (PC: 0x109b901)
Warning: debugging optimized function
47: return n
48: }
49:
50: func main() {
51: // Create the network
=> 52: net := NewGreetingApp()
53: // We need a channel to talk to it
54: in := make(chan string)
55: net.SetInPort("In", in)
56: // Run the net
57: wait := goflow.Run(net)
(dlv) b +2 //偏移量2加断点
Breakpoint 2 set at 0x109b90f for main.main() ./main.go:54
(dlv) next //下一个断点
> main.main() ./main.go:54 (hits goroutine(1):1 total:1) (PC: 0x109b90f)
Warning: debugging optimized function
49:
50: func main() {
51: // Create the network
52: net := NewGreetingApp()
53: // We need a channel to talk to it
=> 54: in := make(chan string)
55: net.SetInPort("In", in)
56: // Run the net
57: wait := goflow.Run(net)
58: // Now we can send some names and see what happens
59: in <- "John"
(dlv) n
> main.main() ./main.go:55 (PC: 0x10c1d82)
50: func main() {
51: // Create the network
52: net := NewGreetingApp()
53: // We need a channel to talk to it
54: in := make(chan string)
=> 55: net.SetInPort("In", in)
56: // Run the net
57: wait := goflow.Run(net)
58: // Now we can send some names and see what happens
59: in <- "John"
60: in <- "Boris"
(dlv) p in //打印变量
chan string {
qcount: 0,
dataqsiz: 0,
buf: *[0]string [],
elemsize: 16,
closed: 0,
elemtype: *runtime._type {
size: 16,