Show HN: Dlg – Zero-cost printf-style debugging for Go

Hacker News (score: 39)
Found: July 27, 2025
ID: 587

Description

Code Quality
Show HN: Dlg – Zero-cost printf-style debugging for Go Hey HN,

I tend to use printf-style debugging as my primary troubleshooting method and only resort to gdb as a last resort.

While I like its ease of use printf debugging isn't without its annoyances, namely removing the print statements once you're done.

I used to use trace-level logging from proper logging libraries but adding trace calls in every corner quickly gets out of control and results in an overwhelming amount of output.

To scratch my own itch I created dlg - a minimal debugging library that disappears completely from production builds. Its API exposes just a single function, Printf [1].

dlg is optimized for performance in debug builds and, most importantly, when compiled without the dlg build tag, all calls are eliminated by the Go linker as if dlg was never imported.

For debug builds it adds optional stack trace generation configurable via environment variables or linker flags.

GitHub: https://github.com/vvvvv/dlg

Any feedback is much appreciated.

[1]: Actually two functions - there's also SetOutput.

More from Hacker

ULID: Universally Unique Lexicographically Sortable Identifier

ULID: Universally Unique Lexicographically Sortable Identifier

Debugging BeagleBoard USB boot with a sniffer: fixing omap_loader on modern PCs

Debugging BeagleBoard USB boot with a sniffer: fixing omap_loader on modern PCs

Building a JavaScript Runtime from Scratch using C

Building a JavaScript Runtime from Scratch using C

Show HN: Bolt – A super-fast, statically-typed scripting language written in C

Show HN: Bolt – A super-fast, statically-typed scripting language written in C I&#x27;ve built many interpreters over the years, and Bolt represents my attempt at building the scripting language I always wanted. This is the first public release, 0.1.0!<p>I&#x27;ve felt like most embedded languages have been moving towards safety and typing over years, with things like Python type hints, the explosive popularity of typescript, and even typing in Luau, which powers one of the largest scripted evironments in the world.<p>Bolt attempts to harness this directly in the lagnauge rather than as a preprocessing step, and reap benefits in terms of both safety and performance.<p>I intend to be publishing toys and examples of applications embedding Bolt over the coming few weeks, but be sure to check out the examples and the programming guide in the repo if you&#x27;re interested!

No other tools from this source yet.