Skip to content

Commit

Permalink
refactor: remove useless guard clauses
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jan 18, 2024
1 parent c3e4168 commit 3afc728
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions encoder.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package caddycbrotli

import (
"errors"
"io"

"github.com/google/brotli/go/cbrotli"
)

var errNoWriter = errors.New("no writer")

type encoder struct {
writer *cbrotli.Writer
options cbrotli.WriterOptions
Expand All @@ -19,29 +16,17 @@ func newEncoder(options cbrotli.WriterOptions) *encoder {
}

func (e *encoder) Close() error {
if e.writer == nil {
return errNoWriter
}

err := e.writer.Close()
e.writer = nil

return err
}

func (e *encoder) Flush() error {
if e.writer == nil {
return errNoWriter
}

return e.writer.Flush()
}

func (e *encoder) Write(p []byte) (n int, err error) {
if e.writer == nil {
return 0, errNoWriter
}

return e.writer.Write(p)
}

Expand Down

0 comments on commit 3afc728

Please sign in to comment.