mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
#42: Reverting return values in b64linebreaker.go since return values were defined in signature
This commit is contained in:
parent
a4d927b518
commit
3eb4bc9c52
1 changed files with 5 additions and 8 deletions
|
@ -5,12 +5,9 @@
|
|||
package mail
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
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 {
|
||||
|
@ -25,7 +22,7 @@ var nl = []byte(SingleNewLine)
|
|||
// line length is reached
|
||||
func (l *Base64LineBreaker) Write(b []byte) (n int, err error) {
|
||||
if l.out == nil {
|
||||
return 0, fmt.Errorf(ErrNoOutWriter)
|
||||
return
|
||||
}
|
||||
if l.used+len(b) < MaxBodyLength {
|
||||
copy(l.line[l.used:], b)
|
||||
|
@ -35,19 +32,19 @@ func (l *Base64LineBreaker) Write(b []byte) (n int, err error) {
|
|||
|
||||
n, err = l.out.Write(l.line[0:l.used])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return
|
||||
}
|
||||
excess := MaxBodyLength - l.used
|
||||
l.used = 0
|
||||
|
||||
n, err = l.out.Write(b[0:excess])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return
|
||||
}
|
||||
|
||||
n, err = l.out.Write(nl)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return
|
||||
}
|
||||
|
||||
return l.Write(b[excess:])
|
||||
|
@ -59,7 +56,7 @@ func (l *Base64LineBreaker) Close() (err error) {
|
|||
if l.used > 0 {
|
||||
_, err = l.out.Write(l.line[0:l.used])
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
_, err = l.out.Write(nl)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue