format verb

A placeholder starting with % in a format string, such as %s or %d, that says how to print the matching argument.

In more detail

The daily ones are %s for text, %d for whole numbers, %q for quoted text, %t for booleans, %v for any value in its default form, %+v to include struct field names and %T for the type. %+v is the fastest way to inspect a struct while debugging. In fmt.Errorf, %w also wraps an error.

Examples

fmt.Printf("fields %+v\n", t)
fmt.Printf("type %T\n", t)

Related terms

Taught in

References