You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem. Thanks.
What steps will reproduce the problem?
1. os.MkdirAll("/nonexistant", 0755)
2.
3.
What is the expected output?
[mike]voltron:~> ./mkdir_test
mkdir /zk: permission denied
What do you see instead?
[mike]voltron:~> ./mkdir_test
mkdir : no such file or directory
Which operating system are you using?
Linux.
Here's the fix:
diff -r 9add7892ac1d src/pkg/os/path.go
--- a/src/pkg/os/path.go Tue Mar 22 11:52:41 2011 -0700
+++ b/src/pkg/os/path.go Wed Mar 23 14:34:09 2011 -0700
@@ -33,7 +33,7 @@
j--
}
- if j > 0 {
+ if j > 1 {
// Create parent
err = MkdirAll(path[0:j-1], perm)
if err != nil {
diff -r 9add7892ac1d src/pkg/os/path_test.go
--- a/src/pkg/os/path_test.go Tue Mar 22 11:52:41 2011 -0700
+++ b/src/pkg/os/path_test.go Wed Mar 23 14:34:09 2011 -0700
@@ -179,3 +179,22 @@
t.Errorf("MkdirAll %q: %s", path, err)
}
}
+
+func TestMkdirAllAtSlash(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Log("Skipping test: does windows have /?")
+ return
+ }
+
+ err := MkdirAll("/_test/dir", 0755)
+ if err != nil {
+ pathErr, ok := err.(*PathError)
+ // common for users not to be able to write to /
+ // previously reported erroneously as ENOENT
+ if ok && pathErr.Error == EACCES {
+ return
+ }
+ t.Fatalf(`MkdirAll "/_test/dir": %v`, err)
+ }
+ defer RemoveAll("/_test/dir")
+}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: