Format a string without printing it

yourbasic.org/golang

The fmt.Sprintf function formats a string in the same way as fmt.Printf, but returns the string instead of printing it.

s := fmt.Sprintf("Size: %d MB.", 85) // s == "Size: 85 MB."

Further reading

fmt cheat sheet