Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
73d57642
Commit
73d57642
authored
Jun 01, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filepath: remove string constants. They are unnecessary.
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/4527090
parent
581bd378
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
src/cmd/goinstall/path.go
src/cmd/goinstall/path.go
+1
-1
src/pkg/path/filepath/path.go
src/pkg/path/filepath/path.go
+8
-10
No files found.
src/cmd/goinstall/path.go
View file @
73d57642
...
@@ -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
}
}
...
...
src/pkg/path/filepath/path.go
View file @
73d57642
...
@@ -15,10 +15,8 @@ import (
...
@@ -15,10 +15,8 @@ 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
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment