fmt.Sprintf
The fmt function that builds a string from a format string and arguments and returns it instead of printing it.
In more detail
Use it to assemble log lines, addresses or messages, such as fmt.Sprintf("%s:%d", host, port). It uses the same verbs as Printf.
Example
line := fmt.Sprintf("%s:%d", t.Host, t.Port)Related terms
- fmt.Printf — The fmt function that prints text built from a format string, in which verbs such as %s and %d are replaced by the arguments.
- format verb — A placeholder starting with % in a format string, such as %s or %d, that says how to print the matching argument.
Taught in
- Go Workspaces and Modules — Concurrent Systems Programming with Go
- Your First Program and go run — Concurrent Systems Programming with Go
- Structs and Methods — Concurrent Systems Programming with Go