diff --git a/README.md b/README.md index 27fefd0..1fd0eab 100644 --- a/README.md +++ b/README.md @@ -140,3 +140,75 @@ type File interface { } ``` +These two interfaces, along with the [`os#FileInfo`](https://godoc.org/os#FileInfo), provide the bulk of the API surface area. + +### Open + +```go +func run() error { + f, err := pkger.Open("/public/index.html") + if err != nil { + return err + } + defer f.Close() + + info, err := f.Stat() + if err != nil { + return err + } + + fmt.Println("Name: ", info.Name()) + fmt.Println("Size: ", info.Size()) + fmt.Println("Mode: ", info.Mode()) + fmt.Println("ModTime: ", info.ModTime()) + + if _, err := io.Copy(os.Stdout, f); err != nil { + return err + } + return nil +} +``` + +### Stat + +```go +func run() error { + info, err := pkger.Stat("/public/index.html") + if err != nil { + return err + } + + fmt.Println("Name: ", info.Name()) + fmt.Println("Size: ", info.Size()) + fmt.Println("Mode: ", info.Mode()) + fmt.Println("ModTime: ", info.ModTime()) + + return nil +} +``` + +### Walk + +```go +func run() error { + w := tabwriter.NewWriter(os.Stdout, 0, 0, 0, ' ', tabwriter.Debug) + defer w.Flush() + + return pkger.Walk("/public", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + fmt.Fprintf(w, + "%s \t %d \t %s \t %s \t\n", + info.Name(), + info.Size(), + info.Mode(), + info.ModTime().Format(time.RFC3339), + ) + + return nil + }) + +} +``` diff --git a/version.go b/version.go index b01fb40..52ecccc 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ package pkger // Version of pkger -const Version = "v0.11.0" +const Version = "v0.12.0"