Go runtime/debug: debugging helpers for Go programs
Answer: Package debug contains facilities for programs to debug themselves while they are running.
Build information and stacks
ReadBuildInfo reports build information embedded in the running binary.
Stack returns a formatted stack trace of the calling goroutine.
SetCrashOutput can send additional crash output to a chosen file.
Garbage collection controls
SetGCPercent sets the garbage collection target percentage.
FreeOSMemory runs a collection and returns unused memory to the operating system.
ReadGCStats fills a GCStats value with recent garbage collection data, including pause history.
See also
Claims
- id: C1 claim: The package helps programs debug themselves while they are running. source: S1 evidence: "Package debug contains facilities for programs to debug themselves while they are running."
- id: C2 claim: ReadGCStats reads statistics about garbage collection into stats. source: S2 evidence: "ReadGCStats reads statistics about garbage collection into stats."
- id: C3 claim: SetGCPercent sets the garbage collection target percentage. source: S1 evidence: "SetGCPercent sets the garbage collection target percentage"
- id: C4 claim: The number of entries in the pause history is system-dependent. source: S2 evidence: "The number of entries in the pause history is system-dependent"
Sources
- [S1] runtime/debug. The Go Authors. https://pkg.go.dev/runtime/debug . License: BSD-3-Clause. Accessed 2026-11-24.
- [S2] runtime/debug source. The Go Authors. https://go.dev/src/runtime/debug/garbage.go . License: BSD-3-Clause. Accessed 2026-11-24.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, runtime/debug; The Go Authors, runtime/debug source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, runtime/debug; The Go Authors, runtime/debug source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go runtime/debug: debugging helpers for Go programs." iinventedlight Library, iil:note:ypzfe4q3, version of 2026-11-24. https://iinventedlight.com/library/notes/go-rtdebug/. License: CC-BY-4.0.
@misc{iil_note_ypzfe4q3,
author = {{iinventedlight}},
title = {{Go runtime/debug: debugging helpers for Go programs}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/go-rtdebug/},
note = {Permanent ID iil:note:ypzfe4q3. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-rtdebug.schema.json (schema; CC-BY-4.0)
- go-rtdebug.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-rtdebug.md.