From 2fd5967f494d414099b95e22846cc1d9f7753b40 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Wed, 14 Dec 2022 03:28:12 -0800 Subject: [PATCH] initial commits --- content.go | 8 ++++---- errors.go | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 errors.go diff --git a/content.go b/content.go index b33e6b7..772a21d 100644 --- a/content.go +++ b/content.go @@ -134,15 +134,15 @@ func (receiver *Content) Read(p []byte) (int, error) { return 0, errNilByteSlice } + if receiver.Closed() { + return 0, errClosed + } + var reader io.Reader = receiver.reader if nil == reader { return 0, errInternalError } - if receiver.Closed() { - return 0, nil - } - return receiver.reader.Read(p) } diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..6309a23 --- /dev/null +++ b/errors.go @@ -0,0 +1,13 @@ +package strfs + +import ( + "github.com/reiver/go-fck" +) + +const ( + errClosed = fck.Error("closed") + errInternalError = fck.Error("internal error") + errNilByteSlice = fck.Error("nil byte slice") + errNilReader = fck.Error("nil reader") + errNilReceiver = fck.Error("nil receiver") +)