Skip to content

Commit dda32d7

Browse files
committed
fix Windows build
1 parent 1e83c8d commit dda32d7

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

config/v3/fileLoader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"fmt"
1919
"github.com/fstab/grok_exporter/tailer/glob"
2020
"io/ioutil"
21-
"path"
21+
"path/filepath"
2222
)
2323

2424
type ConfigFile struct {
@@ -38,7 +38,7 @@ func NewFileLoader() FileLoader {
3838
}
3939

4040
func (f *fileLoader) LoadDir(dir string) ([]*ConfigFile, error) {
41-
return f.LoadGlob(path.Join(dir, "*"))
41+
return f.LoadGlob(filepath.Join(dir, "*"))
4242
}
4343

4444
func (f *fileLoader) LoadGlob(globString string) ([]*ConfigFile, error) {
@@ -52,7 +52,7 @@ func (f *fileLoader) LoadGlob(globString string) ([]*ConfigFile, error) {
5252
return nil, err
5353
}
5454
for _, fileInfo := range fileInfos {
55-
filePath := path.Join(g.Dir(), fileInfo.Name())
55+
filePath := filepath.Join(g.Dir(), fileInfo.Name())
5656
if g.Match(filePath) {
5757
contents, err := ioutil.ReadFile(filePath)
5858
if err != nil {

config/v3/fileLoader_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package v3
1717
import (
1818
"io/ioutil"
1919
"os"
20-
"path"
2120
"path/filepath"
2221
"strings"
2322
"testing"
@@ -97,11 +96,11 @@ func setUp(t *testing.T) string {
9796
if err != nil {
9897
t.Fatalf("failed to create test directory: %v", err)
9998
}
100-
err = ioutil.WriteFile(path.Join(dir, "file1.yaml"), []byte(file1Contents), 0644)
99+
err = ioutil.WriteFile(filepath.Join(dir, "file1.yaml"), []byte(file1Contents), 0644)
101100
if err != nil {
102101
t.Fatalf("unexpected error writing file1.yaml: %v", err)
103102
}
104-
err = ioutil.WriteFile(path.Join(dir, "file2.yaml"), []byte(file2Contents), 0644)
103+
err = ioutil.WriteFile(filepath.Join(dir, "file2.yaml"), []byte(file2Contents), 0644)
105104
if err != nil {
106105
t.Fatalf("unexpected error writing file2.yaml: %v", err)
107106
}

tailer/fswatcher_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"io/ioutil"
2424
"os"
2525
"os/user"
26-
"path"
2726
"path/filepath"
2827
"runtime"
2928
"runtime/pprof"
@@ -384,7 +383,7 @@ func exec(t *testing.T, ctx *context, cmd []string) {
384383
case "log":
385384
writer, exists := ctx.logFileWriters[cmd[2]]
386385
if !exists {
387-
writer = newLogFileWriter(t, ctx, path.Join(ctx.basedir, cmd[2]))
386+
writer = newLogFileWriter(t, ctx, filepath.Join(ctx.basedir, cmd[2]))
388387
ctx.logFileWriters[cmd[2]] = writer
389388
}
390389
writer.writeLine(t, ctx, cmd[1])
@@ -406,7 +405,7 @@ func exec(t *testing.T, ctx *context, cmd []string) {
406405
}
407406

408407
func rotate(t *testing.T, ctx *context, from string, to string) {
409-
fullpath := path.Join(ctx.basedir, from)
408+
fullpath := filepath.Join(ctx.basedir, from)
410409
fromDir := filepath.Dir(fullpath)
411410
filenameFrom := filepath.Base(fullpath)
412411
filesBefore := ls(t, ctx, fromDir)
@@ -463,7 +462,7 @@ func containsFile(files []os.FileInfo, filename string) bool {
463462
}
464463

465464
func moveOrFail(t *testing.T, ctx *context, from, to string) {
466-
fromPath := path.Join(ctx.basedir, from)
465+
fromPath := filepath.Join(ctx.basedir, from)
467466
fromDir := filepath.Dir(fromPath)
468467
fromFilename := filepath.Base(fromPath)
469468
switch {
@@ -494,17 +493,17 @@ func filenames(fileInfos []os.FileInfo) []string {
494493
}
495494

496495
func mvOrFail(t *testing.T, ctx *context, from, to string) {
497-
fromPath := path.Join(ctx.basedir, from)
498-
toPath := path.Join(ctx.basedir, to)
496+
fromPath := filepath.Join(ctx.basedir, from)
497+
toPath := filepath.Join(ctx.basedir, to)
499498
err := os.Rename(fromPath, toPath)
500499
if err != nil {
501500
fatalf(t, ctx, "%v: Failed to mv file: %v", fromPath, err.Error())
502501
}
503502
}
504503

505504
func cpOrFail(t *testing.T, ctx *context, from, to string) {
506-
fromPath := path.Join(ctx.basedir, from)
507-
toPath := path.Join(ctx.basedir, to)
505+
fromPath := filepath.Join(ctx.basedir, from)
506+
toPath := filepath.Join(ctx.basedir, to)
508507
data, err := ioutil.ReadFile(fromPath)
509508
if err != nil {
510509
fatalf(t, ctx, "%v: Copy failed, cannot read file: %v", fromPath, err.Error())
@@ -516,15 +515,15 @@ func cpOrFail(t *testing.T, ctx *context, from, to string) {
516515
}
517516

518517
func rmOrFail(t *testing.T, ctx *context, from string) {
519-
fromPath := path.Join(ctx.basedir, from)
518+
fromPath := filepath.Join(ctx.basedir, from)
520519
err := os.Remove(fromPath)
521520
if err != nil {
522521
fatalf(t, ctx, "%v: Remove failed: %v", fromPath, err.Error())
523522
}
524523
}
525524

526525
func createOrFail(t *testing.T, ctx *context, from string) {
527-
fromPath := path.Join(ctx.basedir, from)
526+
fromPath := filepath.Join(ctx.basedir, from)
528527
dir := filepath.Dir(fromPath)
529528
filename := filepath.Base(fromPath)
530529
filesBeforeCreate := ls(t, ctx, dir)
@@ -546,7 +545,7 @@ func createOrFail(t *testing.T, ctx *context, from string) {
546545
}
547546

548547
func createFromTemp(t *testing.T, ctx *context, from string) {
549-
fromPath := path.Join(ctx.basedir, from)
548+
fromPath := filepath.Join(ctx.basedir, from)
550549
dir := filepath.Dir(fromPath)
551550
filename := filepath.Base(fromPath)
552551
filesBeforeCreate := ls(t, ctx, dir)
@@ -573,7 +572,7 @@ func createFromTemp(t *testing.T, ctx *context, from string) {
573572
}
574573

575574
func truncateOrFail(t *testing.T, ctx *context, from string) {
576-
fromPath := path.Join(ctx.basedir, from)
575+
fromPath := filepath.Join(ctx.basedir, from)
577576
err := os.Truncate(fromPath, 0)
578577
if err != nil {
579578
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) {
585584
fullpath string
586585
err error
587586
)
588-
fullpath = path.Join(ctx.basedir, dirname)
587+
fullpath = filepath.Join(ctx.basedir, dirname)
589588
if _, err = os.Stat(fullpath); !os.IsNotExist(err) {
590589
fatalf(t, ctx, "mkdir %v failed: directory already exists", dirname)
591590
}
@@ -845,7 +844,7 @@ func deleteRecursively(t *testing.T, ctx *context, file string) {
845844
}
846845
if fileInfo.IsDir() {
847846
for _, childInfo := range ls(t, ctx, file) {
848-
deleteRecursively(t, ctx, path.Join(file, childInfo.Name()))
847+
deleteRecursively(t, ctx, filepath.Join(file, childInfo.Name()))
849848
}
850849
}
851850
ctx.log.Debugf("tearDown: removing %q", file)
@@ -938,7 +937,7 @@ func runTestShutdown(t *testing.T, mode string) {
938937
nGoroutinesBefore := runtime.NumGoroutine()
939938

940939
ctx := setUp(t, "test shutdown while "+mode, closeFileAfterEachLine, fseventTailer, _nocreate, mv)
941-
writer := newLogFileWriter(t, ctx, path.Join(ctx.basedir, "test.log"))
940+
writer := newLogFileWriter(t, ctx, filepath.Join(ctx.basedir, "test.log"))
942941
writer.writeLine(t, ctx, "line 1")
943942

944943
parsedGlob, err := glob.Parse(filepath.Join(ctx.basedir, "test.log"))

0 commit comments

Comments
 (0)