From 764bbd9897157d4f7926aedd3c76a65b177febfc Mon Sep 17 00:00:00 2001 From: slene Date: Thu, 19 Dec 2013 19:04:57 +0800 Subject: [PATCH] #390 should use filepath.Dir instead of path.Dir for. --- cache/file.go | 12 ++++++------ logs/file.go | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cache/file.go b/cache/file.go index 8508c1d1..4612ee16 100644 --- a/cache/file.go +++ b/cache/file.go @@ -14,7 +14,7 @@ import ( "fmt" "io" "os" - "path" + "path/filepath" "reflect" "strconv" "time" @@ -79,8 +79,8 @@ func (this *FileCache) StartAndGC(config string) error { } func (this *FileCache) Init() { - app := path.Dir(os.Args[0]) - this.CachePath = path.Join(app, this.CachePath) + app := filepath.Dir(os.Args[0]) + this.CachePath = filepath.Join(app, this.CachePath) ok, err := exists(this.CachePath) if err != nil { // print error //fmt.Println(err) @@ -102,9 +102,9 @@ func (this *FileCache) getCacheFileName(key string) string { //fmt.Println("md5" , keyMd5); switch this.DirectoryLevel { case 2: - cachePath = path.Join(cachePath, keyMd5[0:2], keyMd5[2:4]) + cachePath = filepath.Join(cachePath, keyMd5[0:2], keyMd5[2:4]) case 1: - cachePath = path.Join(cachePath, keyMd5[0:2]) + cachePath = filepath.Join(cachePath, keyMd5[0:2]) } ok, err := exists(cachePath) @@ -116,7 +116,7 @@ func (this *FileCache) getCacheFileName(key string) string { //fmt.Println(err); } } - return path.Join(cachePath, fmt.Sprintf("%s%s", keyMd5, this.FileSuffix)) + return filepath.Join(cachePath, fmt.Sprintf("%s%s", keyMd5, this.FileSuffix)) } func (this *FileCache) Get(key string) interface{} { diff --git a/logs/file.go b/logs/file.go index 9cb796af..e19c6c7f 100644 --- a/logs/file.go +++ b/logs/file.go @@ -7,7 +7,6 @@ import ( "io/ioutil" "log" "os" - "path" "path/filepath" "strings" "sync" @@ -201,7 +200,7 @@ func (w *FileLogWriter) DoRotate() error { } func (w *FileLogWriter) deleteOldLog() { - dir := path.Dir(w.Filename) + dir := filepath.Dir(w.Filename) filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) { if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {