
Go Debugging with Delve, or No More Fmt.Printfs - tpaschalis
https://tpaschalis.github.io/delve-debugging/
======
sn_master
Coming to Go from C#, I was shocked at how poor the debugging experience was,
even inside Google itself (I worked at GCP for less than a year).

I don't get the mentality of people who don't feel the importance and
satisfaction of being able to step through their code line-by-line and see
everything coming to life in a debugger window, even if its for sake of
watching it, not for finding a code bug. Some people seem to never have used
one for years and they take it as a sign of weakness if someone says they need
one to find a bug rather than looking at the code.

I haven't and if its up to me, I would never use Go again, just because of the
piss poor debugging experience in a language that's so new. Google engineer's
mentality is very old school and anyone who enjoyed the beauty of conditional
breakpoints and step-through debugging in modern IDEs will know exactly what I
am talking about. Go is so new yet built with incredibly ancient mentality.

~~~
buffrr
You should try Jetbrains Goland if you're looking for a modern IDE with a
great debugging experience [0]. If you're talking about visual studio being
modern, i don't think that's true. I have used it recently and i was surprised
by how outdated it is (maybe i'm not used to it). Also, I can't seem to do any
changes while the code is running. That's very annoying.

[0][https://www.jetbrains.com/go/](https://www.jetbrains.com/go/)

------
zaphar
I occasionally feel the need to use a debugger. But nothing beats the ease and
power of the humble printf in all it's forms in all languages. Sometimes you
need a debugger. But you can get _really_ far with just a printf.

------
leetrout
Delve is great and debuggers in general are some of the best tools but to take
the title at face value diminishes the value of the unassuming print
facilities in every language.

There’s a time and place for proper debuggers and (more?) time and place for a
simple print statement in my humble opinion.

------
mkchoi212
I remember trying out Delve about a year ago while it was still in its infancy
and don't remember there being commands like `goroutines`; I may be wrong. The
overall experience wasn't all that good to be honest.

My initial impressions of delve was "Oh it's basically GDB for Go". But seems
like the debugger has become more stable and more mature over the years by
shipping language specific commands; like `goroutines`.

~~~
tpaschalis
Yes, the project has gone a long way, as it's being used by what may be the
two most prominent development environments for Go (VSCode and Jetbrains
Goland).

GDB still has a lot of value if you're working with a non-amd64 architecture
or want to dive into cgo parts of a codebase, but Delve is a great addition to
your toolbelt!

------
macrael
The only thing I've seen that seems genuinely better than print debugging most
of the time is the Playground concept, which is just print debugging
automatically for every line of your program. Debuggers seem like they are
useful sometimes, especially if it takes a lot to get into the state you want
to debug, but focusing on making small rapid tests and printing lines that are
interesting to you seems to keep me from ever actually bothering to setup
delve.

~~~
outworlder
> which is just print debugging automatically for every line of your program

Like... a REPL?

~~~
macrael
Playgrounds are like a REPL but they are constantly reevaluating your code
from the beginning, so you can edit code anywhere in the file and see how it
changes everything.

------
tech_dreamer
Go plugin for VS Code has first class support for delve (as well as Emacs) - I
have been using it for more than a year!

~~~
pizza234
It has support, but definitely not first class - I just tried a short time
ago, and it wasn't possible to invoke functions while debugging; GitHub issue
here: [https://github.com/microsoft/vscode-
go/issues/2655](https://github.com/microsoft/vscode-go/issues/2655).

~~~
sn_master
Its a problem with the Go compiler. Even IntelliJ doesn't support that, and
its annoying AF.

------
d0100
As a lifelong printf debugger in many languages, what I'd prefer is to be able
to send my printf's into different streams and have a scrollable, filterable
and searchable console for each stream

Kinda like the console in web developer tools (F12)

~~~
merlinsbrain
Are you looking for the log module, but with a UI on top of it (something like
splunk, but for local development)?

~~~
bubersson
I think we all ultimately want Chrome DevTools features for Go :)

------
btashton
Does anyone have a good workflow for spanning go->cgo. I have found it very
hard to code and debug in the space. I end up using gdb, but that lacks a lot
of the go context and you cannot go into the c code with delve.

~~~
jonathanoliver
This is where I typically resorted to printf statements in pure C.

