dongyong1400 2016-04-03 18:45
浏览 15

用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.

  • 写回答

1条回答 默认 最新

  • dongren9739 2016-04-03 22:06
    关注

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

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

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探