pkger/examples/walk/std/main.go

39 lines
550 B
Go
Raw Permalink Normal View History

2019-10-17 20:45:22 +03:00
package main
import (
"fmt"
"log"
"os"
"path/filepath"
2019-10-18 19:01:48 +03:00
"text/tabwriter"
"time"
2019-10-17 20:45:22 +03:00
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
2019-10-18 19:01:48 +03:00
w := tabwriter.NewWriter(os.Stdout, 0, 0, 0, ' ', tabwriter.Debug)
defer w.Flush()
2019-10-17 20:45:22 +03:00
return filepath.Walk("./public", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
2019-10-18 19:01:48 +03:00
fmt.Fprintf(w,
"%s \t %d \t %s \t %s \t\n",
info.Name(),
info.Size(),
info.Mode(),
info.ModTime().Format(time.RFC3339),
)
2019-10-17 20:45:22 +03:00
return nil
})
}