修复参数不全时会产生额外的换行的BUG

This commit is contained in:
zhiyang7 2021-08-31 09:19:34 +08:00
parent be8576cbcd
commit b9f603452a
1 changed files with 15 additions and 2 deletions

View File

@ -250,11 +250,24 @@ func main() {
} }
msgContent := req.Form.Get("msg") msgContent := req.Form.Get("msg")
if len(msgContent) == 0 { if len(msgContent) == 0 {
textArray := make([]string, 3)
lenOfArr := 0
title := req.Form.Get("title") title := req.Form.Get("title")
if (len(title)) > 0 {
textArray[lenOfArr] = title
lenOfArr++
}
text := req.Form.Get("text") text := req.Form.Get("text")
if (len(text)) > 0 {
textArray[lenOfArr] = text
lenOfArr++
}
desp := req.Form.Get("desp") desp := req.Form.Get("desp")
msgContent = strings.Join([]string{title, text, desp}, "\n") if (len(desp)) > 0 {
log.Println("msgContent=", msgContent) textArray[lenOfArr] = desp
lenOfArr++
}
msgContent = strings.Join(textArray[0:lenOfArr], "\n")
} }
msgType := req.Form.Get("msg_type") msgType := req.Form.Get("msg_type")
if len(msgType) == 0 { if len(msgType) == 0 {