Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "io/ioutil"
- "log"
- "os"
- "path/filepath"
- )
- func main() {
- var (
- root string
- files []string
- err error
- )
- if len(os.Args) == 1 {
- log.Fatal("No path given, Please specify path.")
- return
- }
- if root = os.Args[1]; root == "" {
- log.Fatal("No path given, Please specify path.")
- return
- }
- // filepath.Walk
- files, err = FilePathWalkDir(root)
- if err != nil {
- panic(err)
- }
- // ioutil.ReadDir
- files, err = IOReadDir(root)
- if err != nil {
- panic(err)
- }
- //os.File.Readdir
- files, err = OSReadDir(root)
- if err != nil {
- panic(err)
- }
- for _, file := range files {
- fmt.Println(file)
- }
- }
Add Comment
Please, Sign In to add comment