Simplified some code

This commit is contained in:
Alexandre Cesaro 2015-07-22 22:38:02 +02:00
parent 5a1ac3fca0
commit 07a1f385b7
2 changed files with 5 additions and 5 deletions

View File

@ -200,7 +200,7 @@ func (m *Message) DelHeader(field string) {
// SetBody sets the body of the message. // SetBody sets the body of the message.
func (m *Message) SetBody(contentType, body string) { func (m *Message) SetBody(contentType, body string) {
m.parts = []part{ m.parts = []part{
part{ {
contentType: contentType, contentType: contentType,
copier: func(w io.Writer) error { copier: func(w io.Writer) error {
_, err := io.WriteString(w, body) _, err := io.WriteString(w, body)
@ -243,7 +243,7 @@ func (m *Message) AddAlternative(contentType, body string) {
// }) // })
func (m *Message) AddAlternativeWriter(contentType string, f func(io.Writer) error) { func (m *Message) AddAlternativeWriter(contentType string, f func(io.Writer) error) {
m.parts = []part{ m.parts = []part{
part{ {
contentType: contentType, contentType: contentType,
copier: f, copier: f,
}, },

View File

@ -40,8 +40,8 @@ func (w *messageWriter) writeMessage(m *Message) {
for _, part := range m.parts { for _, part := range m.parts {
contentType := part.contentType + "; charset=" + m.charset contentType := part.contentType + "; charset=" + m.charset
w.writeHeaders(map[string][]string{ w.writeHeaders(map[string][]string{
"Content-Type": []string{contentType}, "Content-Type": {contentType},
"Content-Transfer-Encoding": []string{string(m.encoding)}, "Content-Transfer-Encoding": {string(m.encoding)},
}) })
w.writeBody(part.copier, m.encoding) w.writeBody(part.copier, m.encoding)
} }
@ -91,7 +91,7 @@ func (w *messageWriter) openMultipart(mimeType string) {
w.writeString("\r\n") w.writeString("\r\n")
} else { } else {
w.createPart(map[string][]string{ w.createPart(map[string][]string{
"Content-Type": []string{contentType}, "Content-Type": {contentType},
}) })
} }
w.depth++ w.depth++