Skip to content

Commit

Permalink
added ReaderFunc and WriterFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed May 5, 2015
1 parent c7e5dcf commit 64390f9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions io.go
Expand Up @@ -105,3 +105,17 @@ func WaitForStdin(println ...interface{}) byte {
os.Stdin.Read(buffer)
return buffer[0]
}

// ReaderFunc implements io.Reader as function type with a Read method.
type ReaderFunc func(p []byte) (int, error)

func (f ReaderFunc) Read(p []byte) (int, error) {
return f(p)
}

// WriterFunc implements io.Writer as function type with a Write method.
type WriterFunc func(p []byte) (int, error)

func (f WriterFunc) Write(p []byte) (int, error) {
return f(p)
}

0 comments on commit 64390f9

Please sign in to comment.