Merge pull request #283 from wneessen/bug/279_fix-linter-errors

Fix linter errors
This commit is contained in:
Winni Neessen 2024-08-16 10:22:21 +02:00 committed by GitHub
commit 8efdf49d3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 10 deletions

View file

@ -3,8 +3,9 @@
## SPDX-License-Identifier: MIT ## SPDX-License-Identifier: MIT
[run] [run]
go = "1.22" go = "1.23"
tests = true tests = true
exclude-dirs = ["examples"]
[linters] [linters]
enable = ["stylecheck", "whitespace", "containedctx", "contextcheck", "decorder", enable = ["stylecheck", "whitespace", "containedctx", "contextcheck", "decorder",

View file

@ -5,7 +5,7 @@
package mail package mail
import ( import (
"fmt" "errors"
"io" "io"
) )
@ -26,7 +26,7 @@ var newlineBytes = []byte(SingleNewLine)
// line length is reached // line length is reached
func (l *Base64LineBreaker) Write(data []byte) (numBytes int, err error) { func (l *Base64LineBreaker) Write(data []byte) (numBytes int, err error) {
if l.out == nil { if l.out == nil {
err = fmt.Errorf(ErrNoOutWriter) err = errors.New(ErrNoOutWriter)
return return
} }
if l.used+len(data) < MaxBodyLength { if l.used+len(data) < MaxBodyLength {

12
msg.go
View file

@ -743,7 +743,7 @@ func (m *Msg) SetBodyWriter(
// The content type will be set to text/html automatically // The content type will be set to text/html automatically
func (m *Msg) SetBodyHTMLTemplate(tpl *ht.Template, data interface{}, opts ...PartOption) error { func (m *Msg) SetBodyHTMLTemplate(tpl *ht.Template, data interface{}, opts ...PartOption) error {
if tpl == nil { if tpl == nil {
return fmt.Errorf(errTplPointerNil) return errors.New(errTplPointerNil)
} }
buffer := bytes.Buffer{} buffer := bytes.Buffer{}
if err := tpl.Execute(&buffer, data); err != nil { 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 // The content type will be set to text/plain automatically
func (m *Msg) SetBodyTextTemplate(tpl *tt.Template, data interface{}, opts ...PartOption) error { func (m *Msg) SetBodyTextTemplate(tpl *tt.Template, data interface{}, opts ...PartOption) error {
if tpl == nil { if tpl == nil {
return fmt.Errorf(errTplPointerNil) return errors.New(errTplPointerNil)
} }
buf := bytes.Buffer{} buf := bytes.Buffer{}
if err := tpl.Execute(&buf, data); err != nil { 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 // The content type will be set to text/html automatically
func (m *Msg) AddAlternativeHTMLTemplate(tpl *ht.Template, data interface{}, opts ...PartOption) error { func (m *Msg) AddAlternativeHTMLTemplate(tpl *ht.Template, data interface{}, opts ...PartOption) error {
if tpl == nil { if tpl == nil {
return fmt.Errorf(errTplPointerNil) return errors.New(errTplPointerNil)
} }
buffer := bytes.Buffer{} buffer := bytes.Buffer{}
if err := tpl.Execute(&buffer, data); err != nil { 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 // The content type will be set to text/plain automatically
func (m *Msg) AddAlternativeTextTemplate(tpl *tt.Template, data interface{}, opts ...PartOption) error { func (m *Msg) AddAlternativeTextTemplate(tpl *tt.Template, data interface{}, opts ...PartOption) error {
if tpl == nil { if tpl == nil {
return fmt.Errorf(errTplPointerNil) return errors.New(errTplPointerNil)
} }
buffer := bytes.Buffer{} buffer := bytes.Buffer{}
if err := tpl.Execute(&buffer, data); err != nil { 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 // fileFromHTMLTemplate returns a File pointer form a given html/template.Template
func fileFromHTMLTemplate(name string, tpl *ht.Template, data interface{}) (*File, error) { func fileFromHTMLTemplate(name string, tpl *ht.Template, data interface{}) (*File, error) {
if tpl == nil { if tpl == nil {
return nil, fmt.Errorf(errTplPointerNil) return nil, errors.New(errTplPointerNil)
} }
buffer := bytes.Buffer{} buffer := bytes.Buffer{}
if err := tpl.Execute(&buffer, data); err != nil { 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 // fileFromTextTemplate returns a File pointer form a given text/template.Template
func fileFromTextTemplate(name string, tpl *tt.Template, data interface{}) (*File, error) { func fileFromTextTemplate(name string, tpl *tt.Template, data interface{}) (*File, error) {
if tpl == nil { if tpl == nil {
return nil, fmt.Errorf(errTplPointerNil) return nil, errors.New(errTplPointerNil)
} }
buffer := bytes.Buffer{} buffer := bytes.Buffer{}
if err := tpl.Execute(&buffer, data); err != nil { if err := tpl.Execute(&buffer, data); err != nil {

View file

@ -122,7 +122,7 @@ func TestMsgWriter_writeMsg(t *testing.T) {
em += fmt.Sprintf("* incorrect %q field", ea[e]) em += fmt.Sprintf("* incorrect %q field", ea[e])
} }
em += fmt.Sprintf("\n\nFull message:\n%s", ms) em += fmt.Sprintf("\n\nFull message:\n%s", ms)
t.Errorf(em) t.Error(em)
} }
} }