字符串中允许多个参数[Go]

I'm using Gomail to grab data from a form and email it to myself. If I wanted to get the users full name, this is what I would use:

m.SetBody("text/html", fmt.Sprintf("<b>Full Name</b>: %s", msg.completeName))

It something like this in the email:

Full Name: John Michael Smith

Now if I wanted to add a message field to the code

m.SetBody("text/html", fmt.Sprintf("<b>Full Name</b>: %s", msg.completeName, "<br> <b>Message</b> %s", msg.Content))

It outputs this:

Full Name: John Michael Smith%!(EXTRA string=

Message: %s, string=Hi there!.)

I want it to look like this:

Full Name: John Michael Smith

Message: Hi there!

The issue is that you're using Sprintf the wrong way.

The Sprintf needs a string format as first argument and then all the variables you need to be inserted in the final string.

Thus your code should be:

m.SetBody("text/html", fmt.Sprintf("<b>Full Name</b>: %s <br><b>Message</b> %s", msg.completeName, msg.Content))

For more informations I suggest you to read the Sprintf documentation

NOTE: In the comment I said "why don't you concatenate the string?" since you can also do:

m.SetBody("text/html", "<b>Full Name</b>: "+ msg.completeName +" <br><b>Message</b> " + msg.Content))