How to Debug Golang

Опубликовано: 28 Сентябрь 2024
на канале: Techy Help
4,291
like

Can you tell me how to debug Golang?

It is kind of obvious because that’s when the Golang compiler crashes.

That only tells me there is a bug, not how to fix it.

Go is still immature, with a compiler and garbage collection functions slower than Java because it hasn’t had several iterations to improve. Debuggers short of asking a Go expert to review it is hard to do.

I suppose I could post my code on Stackoverflow and get a programmer’s opinion.

Try searching Stackoverflow or another programming hub on the internet for your question instead of looking like a fifth grader trying to get others to do your work for you.

Since Go is so new, it may not have as many answers as already exist for Java.

The biggest if not the only debugger for Go is the GDB debugger by FSF.

So it isn’t Google.

Google didn’t make it, and they actually broke the single stepping through GDB code function with Go release 1.2.

So Google broke the biggest debugging tool.

Probably oversight, since they try to do everything in house.

Or deliberate, since they don’t want you to use anything but them.

Google’s had plenty of flops. Remember Google Dart?

No.

That’s the programming language they tried to implement prior to Go, and it really missed the mark.

Back to GDB.

You can read the GDB documentation on golang.org. That’s the Go language homepage.

I thought that was Github.

Github is just the biggest code repository for Go language code, aside from Google’s servers. But you could look for Github discussion threads and ask for debugging advice there.

I heard Go could debug itself.

You can use the package debug to try to debug programs while they are running. But Go’s garbage collection can barely pick up the house, much less take it to the curb.