If we need to interpolate a string, without printing it, then we can use
fmt.Sprintf() can also use verbs:
correctAns := "A" answer := fmt.Sprintf("And the correct answer is… %v!", correctAns) fmt.Print(answer) // Prints: And the correct answer is… A!
fmt.Sprintf() works very similarly to
fmt.Printf(), the major difference is that
fmt.Sprintf() returns its value instead of printing it out!
wish the value of calling
fmt.Sprintf() with the values
wish should then contain the interpolated string
"I wish I had a puppy.".