-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc.go
45 lines (45 loc) · 1.21 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Example:
//
// package main
//
// import (
// "context"
// "github.com/whosonfirst/go-reader"
// "io"
// "os"
// )
//
// func main() {
// ctx := context.Background()
// r, _ := reader.NewReader(ctx, "fs:///usr/local/data")
// fh, _ := r.Read(ctx, "example.txt")
// defer fh.Close()
// io.Copy(os.Stdout, fh)
// }
//
// Package reader provides a common interface for reading from a variety of sources. It has the following interface:
//
// type Reader interface {
// Read(context.Context, string) (io.ReadSeekCloser, error)
// ReaderURI(string) string
// }
//
// Reader intstances are created either by calling a package-specific New{SOME_READER}Reader method or by invoking the
// reader.NewReader method passing in a context.Context instance and a URI specific to the reader class. For example:
//
// r, _ := reader.NewReader(ctx, "fs:///usr/local/data")
//
// Custom reader packages implement the reader.Reader interface and register their availability by calling the reader.RegisterRegister
// method on initialization. For example:
//
// func init() {
//
// ctx := context.Background()
//
// err = RegisterReader(ctx, "file", NewFileReader)
//
// if err != nil {
// panic(err)
// }
// }
package reader