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

Taught in

References