diff --git a/README.md b/README.md index abc0329..7c70b52 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ type Path interface { MakePath() error MakePathMode(os.FileMode) error - OpenReader() (io.ReadCloser, error) + OpenReader() (ReadSeekCloser, error) OpenWriter() (*os.File, error) OpenWriterAppend() (*os.File, error) @@ -320,9 +320,9 @@ default given mode #### func (PathImpl) OpenReader ```go -func (path PathImpl) OpenReader() (io.ReadCloser, error) +func (path PathImpl) OpenReader() (ReadSeekCloser, error) ``` -OpenReader retun io.ReaderCloser +OpenReader retun ReadSeekCloser interface for example: @@ -450,6 +450,17 @@ like (slash as separator) for os specific string use Canonpath method func (path PathImpl) Visit(visitFunc VisitFunc, visitOpt VisitOpt) ``` +#### type ReadSeekCloser + +```go +type ReadSeekCloser interface { + io.Reader + io.Seeker + io.Closer +} +``` + + #### type TempOpt ```go diff --git a/VERSION b/VERSION index e69de29..0ea3a94 100644 --- a/VERSION +++ b/VERSION @@ -0,0 +1 @@ +0.2.0 diff --git a/interface.go b/interface.go index 229ca38..08eea3d 100644 --- a/interface.go +++ b/interface.go @@ -42,7 +42,7 @@ type Path interface { MakePath() error MakePathMode(os.FileMode) error - OpenReader() (io.ReadCloser, error) + OpenReader() (ReadSeekCloser, error) OpenWriter() (*os.File, error) OpenWriterAppend() (*os.File, error) diff --git a/open.go b/open.go index 513d7e3..66f1124 100644 --- a/open.go +++ b/open.go @@ -9,7 +9,13 @@ import ( "github.com/pkg/errors" ) -// OpenReader retun io.ReaderCloser +type ReadSeekCloser interface { + io.Reader + io.Seeker + io.Closer +} + +// OpenReader retun ReadSeekCloser interface // // for example: // path, _ := New("/bla/bla") @@ -19,7 +25,7 @@ import ( // } // defer r.Close() // -func (path PathImpl) OpenReader() (io.ReadCloser, error) { +func (path PathImpl) OpenReader() (ReadSeekCloser, error) { file, err := os.Open(path.Canonpath()) if err != nil { return nil, errors.Wrapf(err, "OpenReader on path %s fail (%+v)", path, path)