简体   繁体   中英

Writing two parts of a string in golang

I am just learning golang, and yesterday I created a pretty simple contact form. I just has the user put in their email address and write a simple message. This is how it gets sent in the email:

msg := &Message{
    Email:   r.FormValue("email"),
    Content: r.FormValue("content"),
}

When I get the email, all I get is the content of the message. I am looking to add a lot more fields. So in order for it not to get confusing, I want there to be something like Message: in front of r.FormValue("content"), . This would be something to make the emails more organized.

EDIT : I am so sorry for the confusion, I wrote this in a rush. So basically I have a golang contact form that asks for the users email address and a message. When they hit submit, I get an email that has their address in the subject, and the message in the body. Lets say they put something like: "Hey, my name is Joe, and I would like to get in touch". I would get those same exact words in the body of the email. I am looking to add more textareas, so in order for me not to get confused, it would be great if in front of the message it would say Message: . The whole email body would look like this:

Message: Hey, my name is Joe, and I would like to get in touch.

I am using r.FormValue("content"), to get the contents of the message, now I need a way to add the string Message: in front of it.

Please let me know if you want me to explain it better.

If I understand you correctly, all you need to do is

msg := &Message{
    Email:   r.FormValue("email"),
    Content: "Message: " + r.FormValue("content"),
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM