I have this:
newStr := fmt.Sprintf("new price: %d€", newPrice) fmt.Println(newStr) // new price: %!d(string=500.00)€ // except I want: new price: 500,00€
How to remove the
%!d( and the
) at the end of the string so it can be like this
new price: 500,00€
I could use a format the
strings.Replace but I don’t think it’s the good answer.
newPrice is a float.
I’m pretty sure it as already been ask but it’s hard to google those kind of things.
The problem is that you’re using
%d for an integer value in your call to
fmt.Sprintf(), but passing a floating-point value (500,00).
newStr := fmt.Sprintf("new price: %f€", newPrice) fmt.Println(newStr)
Answered By – m0j0
Answer Checked By – Marilyn (BugsFixing Volunteer)