Go fmt: formatted I/O with printf-style verbs
Answer: Package fmt implements formatted I/O with functions analogous to C printf and scanf. The format verbs are derived from C but are simpler. Println-family functions always add spaces and a newline, while Printf-family functions use verbs.
Examples
fmt.Println("ok")
fmt.Printf("%s %d
", "n", 1)
Notes
There are four families of printing functions, split by output destination. Names such as Printf, Sprintf, Fprintf, and Appendf share the same verb rules.
Reference list
fmtimplements formatted I/O analogous to C printf and scanf.verbscontrol formatting in the Printf family.Printlnalways adds spaces and a newline.
See also
Claims
- id: C1 claim: The format verbs are derived from C but are simpler. source: S1 evidence: "The format 'verbs' are derived from C's but are simpler."
- id: C2 claim: Println-family functions always add spaces and a newline. source: S1 evidence: "Println, Sprintln, Fprintln and Appendln always add spaces and append a newline."
- id: C3 claim: Package fmt implements formatted I/O analogous to C printf and scanf. source: S2 evidence: "Package fmt implements formatted I/O with functions analogous to C's printf and scanf."
Sources
- [S1] fmt package. Go docs. https://pkg.go.dev/fmt . License: BSD-3-Clause. Accessed 2026-11-18.
- [S2] fmt doc.go. Go source. https://raw.githubusercontent.com/golang/go/master/src/fmt/doc.go . License: BSD-3-Clause. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go docs, fmt package; Go source, fmt doc.go. 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: Go docs, fmt package; Go source, fmt doc.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go fmt: formatted I/O with printf-style verbs." iinventedlight Library, iil:note:g9heaeta, version of 2026-11-18. https://iinventedlight.com/library/notes/go-fmt/. License: CC-BY-4.0.
@misc{iil_note_g9heaeta,
author = {{iinventedlight}},
title = {{Go fmt: formatted I/O with printf-style verbs}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/go-fmt/},
note = {Permanent ID iil:note:g9heaeta. 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-fmt.table.json (table; CC-BY-4.0)
- go-fmt.schema.json (schema; 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-fmt.md.