Print a value or a line
#Println appends a newline; Printf applies formatting without adding one unless the format contains it.
Fragment
Import fmt; place calls inside a function.
Reference
Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.
Go docs Package fmt ↗Package bufio ↗
Println appends a newline; Printf applies formatting without adding one unless the format contains it.
Fragment
Import fmt; place calls inside a function.
Fprintln can target stderr. Return errors to an owner that chooses the process status.
Fragment
Import fmt and os. os.Exit skips deferred functions; do cleanup before using it.
The standard slog package supports levels and structured key/value attributes.
Fragment
Go 1.21+. Import log/slog. Configure a handler once when you want JSON or a custom destination.
Println prints with a newline; Printf uses a format without adding one. Sprintf returns the formatted string. strconv.Quote returns a quoted, escaped Go string literal.
Fragment
Imports plus local fragments.
Format verbs choose representation: %d integer, %s string, %v default. Width is a minimum; precision controls digits after the decimal for %f. A 0 flag requests zero padding.
Fragment
Import plus independent fragments.
ReadString reads through and retains the delimiter. It returns text plus an error; EOF can accompany final text. Reuse the buffered reader across reads.
Fragment
Import plus read fragment; no error policy assumed.
Atoi returns (int, error); ParseFloat(text, 64) returns (float64, error). They report invalid syntax/range separately from the value. Neither trims surrounding whitespace.
Fragment
Import plus independent conversion fragments.
Read fills a byte slice and returns (n, error). Only buffer[:n] contains this read’s bytes; process n before handling an accompanying error. Names such as LinePrinter are application-defined, not standard I/O types.
Fragment
Import plus single-read fragment.