#!/usr/bin/expect -f set param [lindex $argv 0]; spawn dlv debug "$param" match_max 100000 expect -exact "Type 'help' for list of commands.\r (dlv) " send -- "break main.main\r" expect "break main.main\r Breakpoint 1 set at * for main.main() ./hello.go:9\r (dlv) " { puts "PASS: break main.main" } send -- "continue\r" expect "continue\r >*main.main() ./hello.go:9 (hits goroutine(1):1 total:1) (PC: 0x*)\r * *=>* 9:*func*main() {\r * (dlv) " { puts "PASS: continue" } send -- "next\r" expect "next\r >*main.main() ./hello.go:10 (PC: 0x*)\r * *=>* 10:*i := *10*\r * (dlv) " { puts "PASS: next" } send -- "break hello_world\r" expect "break hello_world\r Breakpoint 2 set at 0x* for main.hello_world() ./hello.go:5\r (dlv) " { puts "PASS: break hello_world" } send -- "c\r" expect "c\r >*main.hello_world() ./hello.go:5 (hits goroutine(1):1 total:1) (PC: 0x*)\r * *=>* 5:*func* hello_world() {\r * (dlv) " { puts "PASS: c" } send -- "next 4\r" expect "next 4\r Hello World\r > main.main() ./hello.go:13 (PC: 0x*)\r * *=>* 13:*}\r (dlv) " { puts "PASS: next 4" } send -- "locals\r" expect "locals\r* i = 9\r (dlv) " { puts "PASS: locals" } send -- "c\r" expect "c\r Process * has exited with status 0\r (dlv) " { puts "PASS: c (exit)" } send -- "exit\r" expect eof { puts "PASS: exit" }