Debuggin go app

I’ve written a go service and want to debug it. I read on go site that gdb isn’t advised as it is buggy and to use delve instead. However, I follow the instructions on this page: https://github.com/go-delve/delve/blob/master/Documentation/installation/linux/install.md
to install it and when I try to type dlv at command line it says there is no such command.

The instructions are not very good either way, but obviously there is something else to get this working. I have the dlv program in $GOPATH/bin but the OS can’t find it. If I enter $GOPATH/bin/dlv debug I get _cgo_export.c:3:10: fatal error: stdlib.h: No such file or directory

I would have expected better documentation on this since it is the only way to apparently debug go apps.

Are there any sites or

I see that I needed to add my $GOPATH/bin to my main path and have done that. So I can at least run dlv from command line but still getting the error about stdlib.h

1 Like

People here have the same problem runtime/cgo: fails to build after updating to Mojave · Issue #27921 · golang/go · GitHub

Those were all related to osx and xcode, however, it seemed their problem was related to missing the tool chain files for includes. I did a quick search and found the following for anyone interested.

sudo apt install build-essential

This will install the extra include files you need and probably wouldn’t hurt if they at least mentioned it in the docs for delve. But there you go, seems to be working now.

Thanks,

1 Like

BTW: The install instructions for installing go does not tell you to also add ~/go/bin to your path variable which is what was required to be able to debug. So the one way you’re supposed to use to debug go apps, both sides have incomplete instructions for setting it up. Just mentioning in case anyone wants to fix their documents. :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.