snippetgoCritical
Create a io.Reader from a local file
Viewed 0 times
fromreaderfilelocalcreate
Problem
I would like to open a local file, and return a
io.Reader. The reason is that I need to feed a io.Reader to a library I am using, like:func read(r io.Reader) (results []string) {
}Solution
os.Open returns an io.Readerhttp://play.golang.org/p/BskGT09kxL
package main
import (
"fmt"
"io"
"os"
)
var _ io.Reader = (*os.File)(nil)
func main() {
fmt.Println("Hello, playground")
}Code Snippets
package main
import (
"fmt"
"io"
"os"
)
var _ io.Reader = (*os.File)(nil)
func main() {
fmt.Println("Hello, playground")
}Context
Stack Overflow Q#25677235, score: 164
Revisions (0)
No revisions yet.