Hello everyone, we are bringing you to debug the Go program using GDB breakpoint in Ubuntu. Since I have never been familiar with GDB debugging before, and the Go language itself has no built-in debugging tools, unlike Eralng, which can be used by Debugger, I searched the internet, there is no relevant Chinese tutorial, so I have studied it here and I will bring you an article on GDB simple debugging of the Go program. (There are a lot of articles about GDB) First, write the test code as follows: packagemainimpo
Hello everyone, we are bringing you to debug the Go program using GDB breakpoint in Ubuntu. Since I have never been familiar with GDB debugging before, and the Go language itself has no built-in debugging tools, unlike Eralng, which can be used by Debugger, I searched the internet, there is no relevant Chinese tutorial, so I have studied it here and I will bring you an article on GDB simple debugging of the Go program. (There are still a lot of articles about GDB)
First, write the test code as follows:
Package main
Import (
"Fmt"
)
Func main (){
Fmt. Printf ("% s \ n", "hello, world ")
PrintNumber ()
}
Func printNumber (){
Var count int;
Count = 10
Sum: = 0
For I: = 0; I <count; I ++ {
Sum = sum + I
Fmt. Printf ("I = % d, sum = % d \ n", I, sum)
}
}
Compile and run the program (Sublime Text 2 In Ubuntu. If you want to use this tool, refer to my order article: use Sublime Text 2 in Ubuntu to build the Go development environment see http://www.linuxidc.com/Linux/2012-06/62942.htm ):
Go build main. go
./Main