Go: Format a string without printing it

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)
fmt.Println(s)
// Output: Size: 85 MB.

Comments

Be the first to comment!