Standard library / fmt
fmt.Printf()
Writes format-directed text to stdout. The format string specifies verbs and flags; returns bytes written and write error, not a format-validation result. Expected stdout: '0007\n5 <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func Printf(format string, a ...any) (n int, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| format | string | Format string containing literal text and formatting or scanning directives. |
| a | ...any | Values consumed by formatting; may be empty. |
Return Value
(n int, err error)
Number of bytes written and write error.
Working Example
Example Snippetgo
package main
import ( "fmt")
func main() { n, e := fmt.Printf("%04d\n", 7) fmt.Println(n, e)}