From c69a63df8d900e9f018c4768a4385f341dae6b44 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Mon, 11 Nov 2019 17:27:36 -0500 Subject: [PATCH] version bump: v0.12.0 --- README.md | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ version.go | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) 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"