pkger/examples/walk/std/main.go

39 lines
550 B
Go

package main
import (
"fmt"
"log"
"os"
"path/filepath"
"text/tabwriter"
"time"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 0, ' ', tabwriter.Debug)
defer w.Flush()
return filepath.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
})
}