Skip to content

Commit

Permalink
Merge pull request #182 from wneessen/feature/179_refactor-variable-n…
Browse files Browse the repository at this point in the history
…ames-for-readability

Refactor variable names for readability
  • Loading branch information
wneessen authored Feb 27, 2024
2 parents 5c143cb + 514e68b commit 1c883a8
Show file tree
Hide file tree
Showing 21 changed files with 1,087 additions and 1,060 deletions.
22 changes: 11 additions & 11 deletions b64linebreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,39 @@ type Base64LineBreaker struct {
out io.Writer
}

var nl = []byte(SingleNewLine)
var newlineBytes = []byte(SingleNewLine)

// Write writes the data stream and inserts a SingleNewLine when the maximum
// 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 {
err = fmt.Errorf(ErrNoOutWriter)
return
}
if l.used+len(b) < MaxBodyLength {
copy(l.line[l.used:], b)
l.used += len(b)
return len(b), nil
if l.used+len(data) < MaxBodyLength {
copy(l.line[l.used:], data)
l.used += len(data)
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 {
return
}
excess := MaxBodyLength - l.used
l.used = 0

n, err = l.out.Write(b[0:excess])
numBytes, err = l.out.Write(data[0:excess])
if err != nil {
return
}

n, err = l.out.Write(nl)
numBytes, err = l.out.Write(newlineBytes)
if err != nil {
return
}

return l.Write(b[excess:])
return l.Write(data[excess:])
}

// Close closes the Base64LineBreaker and writes any access data that is still
Expand All @@ -63,7 +63,7 @@ func (l *Base64LineBreaker) Close() (err error) {
if err != nil {
return
}
_, err = l.out.Write(nl)
_, err = l.out.Write(newlineBytes)
}

return
Expand Down
Loading

0 comments on commit 1c883a8

Please sign in to comment.