Use path/filepath instead of path for manipulating OS paths.
diff --git a/glog.go b/glog.go
index 8927f93..e951593 100644
--- a/glog.go
+++ b/glog.go
@@ -42,7 +42,7 @@
"fmt"
"io"
"os"
- "path"
+ "path/filepath"
"runtime"
"strconv"
"strings"
@@ -214,7 +214,7 @@
if m.literal {
return file == m.pattern
}
- match, _ := path.Match(m.pattern, file)
+ match, _ := filepath.Match(m.pattern, file)
return match
}
@@ -828,7 +828,7 @@
// setV computes and remembers the V level for a given PC
// when vmodule is enabled.
// File pattern matching takes the basename of the file, stripped
-// of its .go suffix, and uses path.Match, which is a little more
+// of its .go suffix, and uses filepath.Match, which is a little more
// general than the *? matching used in C++.
// l.mu is held.
func (l *loggingT) setV(pc uintptr) Level {
diff --git a/glog_file.go b/glog_file.go
index 097a8e7..1a1ed66 100644
--- a/glog_file.go
+++ b/glog_file.go
@@ -24,7 +24,7 @@
"fmt"
"os"
"os/user"
- "path"
+ "path/filepath"
"strings"
"sync"
"time"
@@ -49,7 +49,7 @@
var (
pid = os.Getpid()
- program = path.Base(os.Args[0])
+ program = filepath.Base(os.Args[0])
host = "unknownhost"
userName = "unknownuser"
)
@@ -107,10 +107,10 @@
name, link := logName(tag, t)
var lastErr error
for _, dir := range logDirs {
- fname := path.Join(dir, name)
+ fname := filepath.Join(dir, name)
f, err := os.Create(fname)
if err == nil {
- symlink := path.Join(dir, link)
+ symlink := filepath.Join(dir, link)
os.Remove(symlink) // ignore err
os.Symlink(fname, symlink) // ignore err
return f, fname, nil
diff --git a/glog_test.go b/glog_test.go
index 92ccc46..e4cac5a 100644
--- a/glog_test.go
+++ b/glog_test.go
@@ -19,6 +19,7 @@
import (
"bytes"
"fmt"
+ "path/filepath"
"runtime"
"strings"
"testing"
@@ -299,9 +300,7 @@
if !ok {
t.Fatal("could not get file:line")
}
- if i := strings.LastIndex(file, "/"); i >= 0 {
- file = file[i+1:]
- }
+ _, file = filepath.Split(file)
infoLine = fmt.Sprintf("%s:%d", file, line+delta)
err := logging.traceLocation.Set(infoLine)
if err != nil {