diff --git a/b64linebreaker.go b/b64linebreaker.go index f5fb967..088b38e 100644 --- a/b64linebreaker.go +++ b/b64linebreaker.go @@ -5,7 +5,7 @@ package mail import ( - "fmt" + "errors" "io" ) @@ -26,7 +26,7 @@ var newlineBytes = []byte(SingleNewLine) // line length is reached func (l *Base64LineBreaker) Write(data []byte) (numBytes int, err error) { if l.out == nil { - err = fmt.Errorf(ErrNoOutWriter) + err = errors.New(ErrNoOutWriter) return } if l.used+len(data) < MaxBodyLength { diff --git a/msg.go b/msg.go index c0333f2..a909d04 100644 --- a/msg.go +++ b/msg.go @@ -743,7 +743,7 @@ func (m *Msg) SetBodyWriter( // The content type will be set to text/html automatically func (m *Msg) SetBodyHTMLTemplate(tpl *ht.Template, data interface{}, opts ...PartOption) error { if tpl == nil { - return fmt.Errorf(errTplPointerNil) + return errors.New(errTplPointerNil) } buffer := bytes.Buffer{} if err := tpl.Execute(&buffer, data); err != nil { @@ -758,7 +758,7 @@ func (m *Msg) SetBodyHTMLTemplate(tpl *ht.Template, data interface{}, opts ...Pa // The content type will be set to text/plain automatically func (m *Msg) SetBodyTextTemplate(tpl *tt.Template, data interface{}, opts ...PartOption) error { if tpl == nil { - return fmt.Errorf(errTplPointerNil) + return errors.New(errTplPointerNil) } buf := bytes.Buffer{} if err := tpl.Execute(&buf, data); err != nil { @@ -790,7 +790,7 @@ func (m *Msg) AddAlternativeWriter( // The content type will be set to text/html automatically func (m *Msg) AddAlternativeHTMLTemplate(tpl *ht.Template, data interface{}, opts ...PartOption) error { if tpl == nil { - return fmt.Errorf(errTplPointerNil) + return errors.New(errTplPointerNil) } buffer := bytes.Buffer{} if err := tpl.Execute(&buffer, data); err != nil { @@ -805,7 +805,7 @@ func (m *Msg) AddAlternativeHTMLTemplate(tpl *ht.Template, data interface{}, opt // The content type will be set to text/plain automatically func (m *Msg) AddAlternativeTextTemplate(tpl *tt.Template, data interface{}, opts ...PartOption) error { if tpl == nil { - return fmt.Errorf(errTplPointerNil) + return errors.New(errTplPointerNil) } buffer := bytes.Buffer{} if err := tpl.Execute(&buffer, data); err != nil { @@ -1314,7 +1314,7 @@ func fileFromReadSeeker(name string, reader io.ReadSeeker) *File { // fileFromHTMLTemplate returns a File pointer form a given html/template.Template func fileFromHTMLTemplate(name string, tpl *ht.Template, data interface{}) (*File, error) { if tpl == nil { - return nil, fmt.Errorf(errTplPointerNil) + return nil, errors.New(errTplPointerNil) } buffer := bytes.Buffer{} if err := tpl.Execute(&buffer, data); err != nil { @@ -1326,7 +1326,7 @@ func fileFromHTMLTemplate(name string, tpl *ht.Template, data interface{}) (*Fil // fileFromTextTemplate returns a File pointer form a given text/template.Template func fileFromTextTemplate(name string, tpl *tt.Template, data interface{}) (*File, error) { if tpl == nil { - return nil, fmt.Errorf(errTplPointerNil) + return nil, errors.New(errTplPointerNil) } buffer := bytes.Buffer{} if err := tpl.Execute(&buffer, data); err != nil { diff --git a/msgwriter_test.go b/msgwriter_test.go index e6582fb..a41e5d3 100644 --- a/msgwriter_test.go +++ b/msgwriter_test.go @@ -122,7 +122,7 @@ func TestMsgWriter_writeMsg(t *testing.T) { em += fmt.Sprintf("* incorrect %q field", ea[e]) } em += fmt.Sprintf("\n\nFull message:\n%s", ms) - t.Errorf(em) + t.Error(em) } }