Skip to content

Commit

Permalink
add Close methods to smfreader and smfwriter
Browse files Browse the repository at this point in the history
  • Loading branch information
metakeule committed Sep 3, 2018
1 parent 83eaf07 commit 3528d06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions smf/smfreader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ func New(src io.Reader, opts ...Option) smf.Reader {
return rd
}

// Close closes the internal reader if it is an io.ReadCloser
func (r *reader) Close() error {
if cl, is := r.input.(io.ReadCloser); is {
return cl.Close()
}
return nil
}

func (r *reader) ReadHeader() error {
if r.headerIsRead {
return r.error
Expand Down
7 changes: 7 additions & 0 deletions smf/smfwriter/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ type writer struct {
runningWriter runningstatus.SMFWriter
}

func (w *writer) Close() error {
if cl, is := w.output.(io.WriteCloser); is {
return cl.Close()
}
return nil
}

func (w *writer) WriteHeader() error {
if w.headerWritten {
return w.error
Expand Down

0 comments on commit 3528d06

Please sign in to comment.