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
42effdf0
Commit
42effdf0
authored
Jul 19, 2011
by
Alex Brainman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/build: fixes for windows paths
R=golang-dev, mattn.jp, adg CC=golang-dev
https://golang.org/cl/4746047
parent
98f5fc5e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
12 deletions
+37
-12
src/pkg/go/build/path.go
src/pkg/go/build/path.go
+6
-3
src/pkg/path/filepath/path.go
src/pkg/path/filepath/path.go
+1
-1
src/pkg/path/filepath/path_plan9.go
src/pkg/path/filepath/path_plan9.go
+7
-2
src/pkg/path/filepath/path_unix.go
src/pkg/path/filepath/path_unix.go
+7
-2
src/pkg/path/filepath/path_windows.go
src/pkg/path/filepath/path_windows.go
+16
-4
No files found.
src/pkg/go/build/path.go
View file @
42effdf0
...
...
@@ -10,7 +10,6 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
)
// Path is a validated list of Trees derived from $GOROOT and $GOPATH at init.
...
...
@@ -96,7 +95,7 @@ func FindTree(path string) (tree *Tree, pkg string, err os.Error) {
}
for
_
,
t
:=
range
Path
{
tpath
:=
t
.
SrcDir
()
+
string
(
filepath
.
Separator
)
if
!
strings
.
HasPrefix
(
path
,
tpath
)
{
if
!
filepath
.
HasPrefix
(
path
,
tpath
)
{
continue
}
tree
=
t
...
...
@@ -123,9 +122,13 @@ func FindTree(path string) (tree *Tree, pkg string, err os.Error) {
}
// isLocalPath returns whether the given path is local (/foo ./foo ../foo . ..)
// Windows paths that starts with drive letter (c:\foo c:foo) are considered local.
func
isLocalPath
(
s
string
)
bool
{
const
sep
=
string
(
filepath
.
Separator
)
return
strings
.
HasPrefix
(
s
,
sep
)
||
strings
.
HasPrefix
(
s
,
"."
+
sep
)
||
strings
.
HasPrefix
(
s
,
".."
+
sep
)
||
s
==
"."
||
s
==
".."
return
s
==
"."
||
s
==
".."
||
filepath
.
HasPrefix
(
s
,
sep
)
||
filepath
.
HasPrefix
(
s
,
"."
+
sep
)
||
filepath
.
HasPrefix
(
s
,
".."
+
sep
)
||
filepath
.
VolumeName
(
s
)
!=
""
}
var
(
...
...
src/pkg/path/filepath/path.go
View file @
42effdf0
...
...
@@ -38,7 +38,7 @@ const (
// Getting Dot-Dot right,''
// http://plan9.bell-labs.com/sys/doc/lexnames.html
func
Clean
(
path
string
)
string
{
vol
:=
v
olumeName
(
path
)
vol
:=
V
olumeName
(
path
)
path
=
path
[
len
(
vol
)
:
]
if
path
==
""
{
return
vol
+
"."
...
...
src/pkg/path/filepath/path_plan9.go
View file @
42effdf0
...
...
@@ -11,8 +11,13 @@ func IsAbs(path string) bool {
return
strings
.
HasPrefix
(
path
,
"/"
)
||
strings
.
HasPrefix
(
path
,
"#"
)
}
//
v
olumeName returns the leading volume name on Windows.
//
V
olumeName returns the leading volume name on Windows.
// It returns "" elsewhere
func
v
olumeName
(
path
string
)
string
{
func
V
olumeName
(
path
string
)
string
{
return
""
}
// HasPrefix tests whether the path p begins with prefix.
func
HasPrefix
(
p
,
prefix
string
)
bool
{
return
strings
.
HasPrefix
(
p
,
prefix
)
}
src/pkg/path/filepath/path_unix.go
View file @
42effdf0
...
...
@@ -11,8 +11,13 @@ func IsAbs(path string) bool {
return
strings
.
HasPrefix
(
path
,
"/"
)
}
//
v
olumeName returns the leading volume name on Windows.
//
V
olumeName returns the leading volume name on Windows.
// It returns "" elsewhere.
func
v
olumeName
(
path
string
)
string
{
func
V
olumeName
(
path
string
)
string
{
return
""
}
// HasPrefix tests whether the path p begins with prefix.
func
HasPrefix
(
p
,
prefix
string
)
bool
{
return
strings
.
HasPrefix
(
p
,
prefix
)
}
src/pkg/path/filepath/path_windows.go
View file @
42effdf0
...
...
@@ -4,9 +4,11 @@
package
filepath
import
"strings"
// IsAbs returns true if the path is absolute.
func
IsAbs
(
path
string
)
(
b
bool
)
{
v
:=
v
olumeName
(
path
)
v
:=
V
olumeName
(
path
)
if
v
==
""
{
return
false
}
...
...
@@ -17,9 +19,10 @@ func IsAbs(path string) (b bool) {
return
path
[
0
]
==
'/'
||
path
[
0
]
==
'\\'
}
// volumeName return leading volume name.
// If given "C:\foo\bar", return "C:" on windows.
func
volumeName
(
path
string
)
(
v
string
)
{
// VolumeName returns leading volume name.
// Given "C:\foo\bar" it returns "C:" under windows.
// On other platforms it returns "".
func
VolumeName
(
path
string
)
(
v
string
)
{
if
len
(
path
)
<
2
{
return
""
}
...
...
@@ -32,3 +35,12 @@ func volumeName(path string) (v string) {
}
return
""
}
// HasPrefix tests whether the path p begins with prefix.
// It ignores case while comparing.
func
HasPrefix
(
p
,
prefix
string
)
bool
{
if
strings
.
HasPrefix
(
p
,
prefix
)
{
return
true
}
return
strings
.
HasPrefix
(
strings
.
ToLower
(
p
),
strings
.
ToLower
(
prefix
))
}
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