mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Refactor variable and function names for improved clarity in b64linebreaker.go
The existing variable and function names in the file have been updated for better readability. This change aids in code comprehension without affecting its functionality or logic. With accurately depicted names, the maintainability of the code is enhanced.
This commit is contained in:
parent
c455b45a3e
commit
d81dee95a8
1 changed files with 11 additions and 11 deletions
|
@ -20,39 +20,39 @@ type Base64LineBreaker struct {
|
||||||
out io.Writer
|
out io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
var nl = []byte(SingleNewLine)
|
var newlineBytes = []byte(SingleNewLine)
|
||||||
|
|
||||||
// Write writes the data stream and inserts a SingleNewLine when the maximum
|
// Write writes the data stream and inserts a SingleNewLine when the maximum
|
||||||
// line length is reached
|
// line length is reached
|
||||||
func (l *Base64LineBreaker) Write(b []byte) (n 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 = fmt.Errorf(ErrNoOutWriter)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if l.used+len(b) < MaxBodyLength {
|
if l.used+len(data) < MaxBodyLength {
|
||||||
copy(l.line[l.used:], b)
|
copy(l.line[l.used:], data)
|
||||||
l.used += len(b)
|
l.used += len(data)
|
||||||
return len(b), nil
|
return len(data), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err = l.out.Write(l.line[0:l.used])
|
numBytes, err = l.out.Write(l.line[0:l.used])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
excess := MaxBodyLength - l.used
|
excess := MaxBodyLength - l.used
|
||||||
l.used = 0
|
l.used = 0
|
||||||
|
|
||||||
n, err = l.out.Write(b[0:excess])
|
numBytes, err = l.out.Write(data[0:excess])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err = l.out.Write(nl)
|
numBytes, err = l.out.Write(newlineBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return l.Write(b[excess:])
|
return l.Write(data[excess:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the Base64LineBreaker and writes any access data that is still
|
// Close closes the Base64LineBreaker and writes any access data that is still
|
||||||
|
@ -63,7 +63,7 @@ func (l *Base64LineBreaker) Close() (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = l.out.Write(nl)
|
_, err = l.out.Write(newlineBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue