Sprintf formats according to a format specifier and returns the resulting string.
package main import ( "fmt" "io" "os" ) func main() { const name, age = "Kim", 22 s := fmt.Sprintf("%s is %d years old.\n", name, age) io.WriteString(os.Stdout, s) // Ignoring error for simplicity. }