From b41d34de39c1aacf039ff7ecfc811973859b3a06 Mon Sep 17 00:00:00 2001 From: David Stark Date: Mon, 9 Dec 2019 22:23:59 +0000 Subject: [PATCH] cleanup --- playground/3-find-files/files.go | 51 ------------------------------- playground/3-find-files/test1.log | 2 -- playground/3-find-files/test2.log | 0 3 files changed, 53 deletions(-) delete mode 100644 playground/3-find-files/files.go delete mode 100644 playground/3-find-files/test1.log delete mode 100644 playground/3-find-files/test2.log diff --git a/playground/3-find-files/files.go b/playground/3-find-files/files.go deleted file mode 100644 index c2d6371..0000000 --- a/playground/3-find-files/files.go +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "fmt" - "log" - "os" - "os/user" - "path/filepath" - "strings" -) - -func TrimSuffix(s, suffix string) string { - if strings.HasSuffix(s, suffix) { - s = s[:len(s)-len(suffix)] - } - return s -} - -func main() { - var searchPath []string - searchPath = append(searchPath, - "/home/starkers/.local/share/Steam/steamapps/compatdata/8500/pfx/drive_c/users/steamuser/My Documents/EVE/logs/Chatlogs") - - usr, _ := user.Current() - dir := usr.HomeDir - - for _, d := range searchPath { - - // if has trailing slash, remove it - d = TrimSuffix(d, "/") - - // do a unix like expansion if the path starts like `~/` - if strings.HasPrefix(d, "~/") { - d = filepath.Join(dir, d[2:]) - } - f, err := os.Open(d) - if err != nil { - log.Fatal(err) - } - files, err := f.Readdir(-1) - f.Close() - if err != nil { - log.Fatal(err) - } - - for _, file := range files { - fmt.Printf("%v/%v\n", d, file.Name()) - } - } - -} diff --git a/playground/3-find-files/test1.log b/playground/3-find-files/test1.log deleted file mode 100644 index bfc04a9..0000000 --- a/playground/3-find-files/test1.log +++ /dev/null @@ -1,2 +0,0 @@ -11 -22 diff --git a/playground/3-find-files/test2.log b/playground/3-find-files/test2.log deleted file mode 100644 index e69de29..0000000