Commit 73d57642 authored by Rob Pike's avatar Rob Pike

filepath: remove string constants. They are unnecessary.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4527090
parent 581bd378
...@@ -119,7 +119,7 @@ func findPackageRoot(path string) (root *pkgroot, pkg string, err os.Error) { ...@@ -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
} }
......
...@@ -17,8 +17,6 @@ import ( ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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) { ...@@ -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) { ...@@ -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 { ...@@ -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
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment