Skip to content

Commit

Permalink
Merge pull request #2 from JaSei/open_reader_read_seek_closer_interface
Browse files Browse the repository at this point in the history
OpenReader return ReadSeekCloser
  • Loading branch information
JaSei authored Mar 13, 2018
2 parents 97594f1 + 01c43f2 commit 046e1d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.0
2 changes: 1 addition & 1 deletion interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 8 additions & 2 deletions open.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down

0 comments on commit 046e1d4

Please sign in to comment.