1
0
mirror of https://github.com/golang/go synced 2024-11-22 01:04:40 -07:00

filepath: remove string constants. They are unnecessary.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4527090
This commit is contained in:
Rob Pike 2011-06-01 13:06:04 +10:00
parent 581bd378ec
commit 73d57642a4
2 changed files with 9 additions and 11 deletions

View File

@ -119,7 +119,7 @@ func findPackageRoot(path string) (root *pkgroot, pkg string, err os.Error) {
return return
} }
for _, r := range gopath { for _, r := range gopath {
rpath := r.srcDir() + filepath.SeparatorString rpath := r.srcDir() + string(filepath.Separator)
if !strings.HasPrefix(path, rpath) { if !strings.HasPrefix(path, rpath) {
continue continue
} }

View File

@ -17,8 +17,6 @@ import (
const ( const (
Separator = os.PathSeparator Separator = os.PathSeparator
ListSeparator = os.PathListSeparator ListSeparator = os.PathListSeparator
SeparatorString = string(Separator)
ListSeparatorString = string(ListSeparator)
) )
// Clean returns the shortest path name equivalent to path // Clean returns the shortest path name equivalent to path
@ -121,7 +119,7 @@ func ToSlash(path string) string {
if Separator == '/' { if Separator == '/' {
return path return path
} }
return strings.Replace(path, SeparatorString, "/", -1) return strings.Replace(path, string(Separator), "/", -1)
} }
// FromSlash returns the result of replacing each slash ('/') character // FromSlash returns the result of replacing each slash ('/') character
@ -130,7 +128,7 @@ func FromSlash(path string) string {
if Separator == '/' { if Separator == '/' {
return path return path
} }
return strings.Replace(path, "/", SeparatorString, -1) return strings.Replace(path, "/", string(Separator), -1)
} }
// SplitList splits a list of paths joined by the OS-specific ListSeparator. // SplitList splits a list of paths joined by the OS-specific ListSeparator.
@ -138,7 +136,7 @@ func SplitList(path string) []string {
if path == "" { if path == "" {
return []string{} return []string{}
} }
return strings.Split(path, ListSeparatorString, -1) return strings.Split(path, string(ListSeparator), -1)
} }
// Split splits path immediately following the final Separator, // Split splits path immediately following the final Separator,
@ -158,7 +156,7 @@ func Split(path string) (dir, file string) {
func Join(elem ...string) string { func Join(elem ...string) string {
for i, e := range elem { for i, e := range elem {
if e != "" { if e != "" {
return Clean(strings.Join(elem[i:], SeparatorString)) return Clean(strings.Join(elem[i:], string(Separator)))
} }
} }
return "" return ""
@ -236,7 +234,7 @@ func EvalSymlinks(path string) (string, os.Error) {
if IsAbs(dest) { if IsAbs(dest) {
b.Reset() b.Reset()
} }
path = dest + SeparatorString + path path = dest + string(Separator) + path
} }
return Clean(b.String()), nil return Clean(b.String()), nil
} }
@ -354,7 +352,7 @@ func Base(path string) string {
} }
// If empty now, it had only slashes. // If empty now, it had only slashes.
if path == "" { if path == "" {
return SeparatorString return string(Separator)
} }
return path return path
} }