Preface
Recently, from 2020/02/01 to 02/02 (FOSDEM: Free and Open source Software Developers’ European Meeting), which is the largest open-source developer conference in Europe (can it be explained as the European version of COSCUP?), there was a dedicated Go DevRoom. All the slides and videos have been made public. Welcome everyone to dig for treasures!!
Slides and Video Links: https://fosdem.org/2020/schedule/track/go/
Advanced debugging techniques of Go code / Andrii Soldatenko
Slides and Video: link
Besides keynote-type topics like "The state of Go", the first one I wanted to understand was this one. It's about advanced debugging techniques in Golang. The debugging skills mentioned mainly rely on the techniques provided by https://github.com/go-delve/delve. The relevant techniques include:
- How to attach by delve
- How to set conditional breakpoints
- How to run unit tests through delve, i.e., run test functions through delve
- I personally love using this and use it very often.
- You can even use eval in Goland to quickly query related values
The final technique introduced is remote debugging a docker container through delve. By exposing the web app's port through docker port, it's forwarded to delve (e.g., port 40000). Then, you can attach the delve debugger through port 40000.
Finally, you might be curious, isn't GDB enough for these? But actually, GDB has some small problems:
- GDB on MacOSX requires codesign
- If using MacOSX 10.13, you need to use the older version of GDB 8.0.1 to correctly attach to the Go app
- Because Golang uses
compress dwarfon MacOSX, this will cause the debugging info to not be displayed correctly in GDB. You need to add the following parameters during compilation:go build -ldflags=-compressdwarf=false -gcflags=allto allow GDB to see the symbol
This talk was really practical, and I highly recommend everyone listen to it.

Top comments (0)