diff --git a/config/v3/fileLoader.go b/config/v3/fileLoader.go index 2496c935..6d7f2380 100644 --- a/config/v3/fileLoader.go +++ b/config/v3/fileLoader.go @@ -18,7 +18,7 @@ import ( "fmt" "github.com/fstab/grok_exporter/tailer/glob" "io/ioutil" - "path" + "path/filepath" ) type ConfigFile struct { @@ -38,7 +38,7 @@ func NewFileLoader() FileLoader { } func (f *fileLoader) LoadDir(dir string) ([]*ConfigFile, error) { - return f.LoadGlob(path.Join(dir, "*")) + return f.LoadGlob(filepath.Join(dir, "*")) } func (f *fileLoader) LoadGlob(globString string) ([]*ConfigFile, error) { @@ -52,7 +52,7 @@ func (f *fileLoader) LoadGlob(globString string) ([]*ConfigFile, error) { return nil, err } for _, fileInfo := range fileInfos { - filePath := path.Join(g.Dir(), fileInfo.Name()) + filePath := filepath.Join(g.Dir(), fileInfo.Name()) if g.Match(filePath) { contents, err := ioutil.ReadFile(filePath) if err != nil { diff --git a/config/v3/fileLoader_test.go b/config/v3/fileLoader_test.go index 991c752f..16694b10 100644 --- a/config/v3/fileLoader_test.go +++ b/config/v3/fileLoader_test.go @@ -17,7 +17,6 @@ package v3 import ( "io/ioutil" "os" - "path" "path/filepath" "strings" "testing" @@ -97,11 +96,11 @@ func setUp(t *testing.T) string { if err != nil { t.Fatalf("failed to create test directory: %v", err) } - err = ioutil.WriteFile(path.Join(dir, "file1.yaml"), []byte(file1Contents), 0644) + err = ioutil.WriteFile(filepath.Join(dir, "file1.yaml"), []byte(file1Contents), 0644) if err != nil { t.Fatalf("unexpected error writing file1.yaml: %v", err) } - err = ioutil.WriteFile(path.Join(dir, "file2.yaml"), []byte(file2Contents), 0644) + err = ioutil.WriteFile(filepath.Join(dir, "file2.yaml"), []byte(file2Contents), 0644) if err != nil { t.Fatalf("unexpected error writing file2.yaml: %v", err) } diff --git a/tailer/fswatcher_test.go b/tailer/fswatcher_test.go index ad3c6520..97455f86 100644 --- a/tailer/fswatcher_test.go +++ b/tailer/fswatcher_test.go @@ -23,7 +23,6 @@ import ( "io/ioutil" "os" "os/user" - "path" "path/filepath" "runtime" "runtime/pprof" @@ -384,7 +383,7 @@ func exec(t *testing.T, ctx *context, cmd []string) { case "log": writer, exists := ctx.logFileWriters[cmd[2]] if !exists { - writer = newLogFileWriter(t, ctx, path.Join(ctx.basedir, cmd[2])) + writer = newLogFileWriter(t, ctx, filepath.Join(ctx.basedir, cmd[2])) ctx.logFileWriters[cmd[2]] = writer } writer.writeLine(t, ctx, cmd[1]) @@ -406,7 +405,7 @@ func exec(t *testing.T, ctx *context, cmd []string) { } func rotate(t *testing.T, ctx *context, from string, to string) { - fullpath := path.Join(ctx.basedir, from) + fullpath := filepath.Join(ctx.basedir, from) fromDir := filepath.Dir(fullpath) filenameFrom := filepath.Base(fullpath) filesBefore := ls(t, ctx, fromDir) @@ -463,7 +462,7 @@ func containsFile(files []os.FileInfo, filename string) bool { } func moveOrFail(t *testing.T, ctx *context, from, to string) { - fromPath := path.Join(ctx.basedir, from) + fromPath := filepath.Join(ctx.basedir, from) fromDir := filepath.Dir(fromPath) fromFilename := filepath.Base(fromPath) switch { @@ -494,8 +493,8 @@ func filenames(fileInfos []os.FileInfo) []string { } func mvOrFail(t *testing.T, ctx *context, from, to string) { - fromPath := path.Join(ctx.basedir, from) - toPath := path.Join(ctx.basedir, to) + fromPath := filepath.Join(ctx.basedir, from) + toPath := filepath.Join(ctx.basedir, to) err := os.Rename(fromPath, toPath) if err != nil { fatalf(t, ctx, "%v: Failed to mv file: %v", fromPath, err.Error()) @@ -503,8 +502,8 @@ func mvOrFail(t *testing.T, ctx *context, from, to string) { } func cpOrFail(t *testing.T, ctx *context, from, to string) { - fromPath := path.Join(ctx.basedir, from) - toPath := path.Join(ctx.basedir, to) + fromPath := filepath.Join(ctx.basedir, from) + toPath := filepath.Join(ctx.basedir, to) data, err := ioutil.ReadFile(fromPath) if err != nil { fatalf(t, ctx, "%v: Copy failed, cannot read file: %v", fromPath, err.Error()) @@ -516,7 +515,7 @@ func cpOrFail(t *testing.T, ctx *context, from, to string) { } func rmOrFail(t *testing.T, ctx *context, from string) { - fromPath := path.Join(ctx.basedir, from) + fromPath := filepath.Join(ctx.basedir, from) err := os.Remove(fromPath) if err != nil { fatalf(t, ctx, "%v: Remove failed: %v", fromPath, err.Error()) @@ -524,7 +523,7 @@ func rmOrFail(t *testing.T, ctx *context, from string) { } func createOrFail(t *testing.T, ctx *context, from string) { - fromPath := path.Join(ctx.basedir, from) + fromPath := filepath.Join(ctx.basedir, from) dir := filepath.Dir(fromPath) filename := filepath.Base(fromPath) filesBeforeCreate := ls(t, ctx, dir) @@ -546,7 +545,7 @@ func createOrFail(t *testing.T, ctx *context, from string) { } func createFromTemp(t *testing.T, ctx *context, from string) { - fromPath := path.Join(ctx.basedir, from) + fromPath := filepath.Join(ctx.basedir, from) dir := filepath.Dir(fromPath) filename := filepath.Base(fromPath) filesBeforeCreate := ls(t, ctx, dir) @@ -573,7 +572,7 @@ func createFromTemp(t *testing.T, ctx *context, from string) { } func truncateOrFail(t *testing.T, ctx *context, from string) { - fromPath := path.Join(ctx.basedir, from) + fromPath := filepath.Join(ctx.basedir, from) err := os.Truncate(fromPath, 0) if err != nil { fatalf(t, ctx, "%v: Error truncating the file: %v", from, err.Error()) @@ -585,7 +584,7 @@ func mkdir(t *testing.T, ctx *context, dirname string) { fullpath string err error ) - fullpath = path.Join(ctx.basedir, dirname) + fullpath = filepath.Join(ctx.basedir, dirname) if _, err = os.Stat(fullpath); !os.IsNotExist(err) { fatalf(t, ctx, "mkdir %v failed: directory already exists", dirname) } @@ -845,7 +844,7 @@ func deleteRecursively(t *testing.T, ctx *context, file string) { } if fileInfo.IsDir() { for _, childInfo := range ls(t, ctx, file) { - deleteRecursively(t, ctx, path.Join(file, childInfo.Name())) + deleteRecursively(t, ctx, filepath.Join(file, childInfo.Name())) } } ctx.log.Debugf("tearDown: removing %q", file) @@ -938,7 +937,7 @@ func runTestShutdown(t *testing.T, mode string) { nGoroutinesBefore := runtime.NumGoroutine() ctx := setUp(t, "test shutdown while "+mode, closeFileAfterEachLine, fseventTailer, _nocreate, mv) - writer := newLogFileWriter(t, ctx, path.Join(ctx.basedir, "test.log")) + writer := newLogFileWriter(t, ctx, filepath.Join(ctx.basedir, "test.log")) writer.writeLine(t, ctx, "line 1") parsedGlob, err := glob.Parse(filepath.Join(ctx.basedir, "test.log"))