Skip to content

Commit

Permalink
Use path/filepath instead of path for manipulating OS paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsymonds committed Jul 18, 2013
1 parent 47832e5 commit c2ab0c9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -214,7 +214,7 @@ func (m *modulePat) match(file string) bool {
if m.literal {
return file == m.pattern
}
match, _ := path.Match(m.pattern, file)
match, _ := filepath.Match(m.pattern, file)
return match
}

Expand Down Expand Up @@ -828,7 +828,7 @@ func (l *loggingT) flushAll() {
// 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 {
Expand Down
8 changes: 4 additions & 4 deletions glog_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"fmt"
"os"
"os/user"
"path"
"path/filepath"
"strings"
"sync"
"time"
Expand All @@ -49,7 +49,7 @@ func createLogDirs() {

var (
pid = os.Getpid()
program = path.Base(os.Args[0])
program = filepath.Base(os.Args[0])
host = "unknownhost"
userName = "unknownuser"
)
Expand Down Expand Up @@ -107,10 +107,10 @@ func create(tag string, t time.Time) (f *os.File, filename string, err error) {
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
Expand Down
5 changes: 2 additions & 3 deletions glog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package glog
import (
"bytes"
"fmt"
"path/filepath"
"runtime"
"strings"
"testing"
Expand Down Expand Up @@ -299,9 +300,7 @@ func TestLogBacktraceAt(t *testing.T) {
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 {
Expand Down

0 comments on commit c2ab0c9

Please sign in to comment.