mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 18:50:37 +01:00
#42: Return error in b64linebreaker.go when no out is set
This commit is contained in:
parent
3eb4bc9c52
commit
910248d999
1 changed files with 5 additions and 0 deletions
|
@ -5,9 +5,13 @@
|
|||
package mail
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// ErrNoOutWriter is an error message that should be used if a Base64LineBreaker has no out io.Writer set
|
||||
const ErrNoOutWriter = "no io.Writer set for Base64LineBreaker"
|
||||
|
||||
// Base64LineBreaker is a io.WriteCloser that writes Base64 encoded data streams
|
||||
// with line breaks at a given line length
|
||||
type Base64LineBreaker struct {
|
||||
|
@ -22,6 +26,7 @@ var nl = []byte(SingleNewLine)
|
|||
// line length is reached
|
||||
func (l *Base64LineBreaker) Write(b []byte) (n int, err error) {
|
||||
if l.out == nil {
|
||||
err = fmt.Errorf(ErrNoOutWriter)
|
||||
return
|
||||
}
|
||||
if l.used+len(b) < MaxBodyLength {
|
||||
|
|
Loading…
Reference in a new issue