Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.MkdirAll fails on Windows #1831

Closed
alexbrainman opened this issue May 16, 2011 · 6 comments
Closed

os.MkdirAll fails on Windows #1831

alexbrainman opened this issue May 16, 2011 · 6 comments

Comments

@alexbrainman
Copy link
Member

What steps will reproduce the problem?

build and run

package main

import (
    "fmt"
    "log"
    "os"
    "path/filepath"
)

func main() {
    path := filepath.Clean(`c:\tmp\a\b\c`)
    e := os.MkdirAll(path, 0777)
    if e != nil {
        log.Fatal(e)
    }
    fmt.Printf("All good\n")
}

What is the expected output?

All good

What do you see instead?

2011/05/16 07:33:13 mkdir c:\tmp\a\b\c: The system cannot find the path specified.

Please use labels and text to provide additional information.

hg id returns:
95d2ce135523+ (release-branch.r57) release/release.r57.1

GOOS=windows
GOARCH=386
@gopherbot
Copy link
Contributor

Comment 1 by john.arbash.meinel:

Is it a '\' thing? Given that you have "c:\t" which is probably "C:" "<tab>". But
maybe the `` style quotes mean it ignores escape chars.

@alexbrainman
Copy link
Member Author

Comment 2:

The problem is that os.MkdirAll is "Unix" specific. Among other things it uses '/' as
path delimiter (see http://code.google.com/p/go/source/browse/src/pkg/os/path.go line 27
and 32), while filepath.Clean returns path delimited by '\' on Windows.
Alex

@rsc
Copy link
Contributor

rsc commented May 17, 2011

Comment 3:

Now that we have path/filepath it is possible that MkdirAll and
RemoveAll belong there.

@alexbrainman
Copy link
Member Author

Comment 4:

I was going to ask about that, but you beat me to it. Thank you.
Just these 2, nothing else for now?
Do you expect me to submit gofix patches too?

@rsc
Copy link
Contributor

rsc commented May 17, 2011

Comment 5:

Let's hold off for a little bit.  This is more than gofix can handle
right now since it cannot rewrite imports easily.
Also I would like to think about this for a bit more.

@alexbrainman
Copy link
Member Author

Comment 6:

This issue was closed by revision 0f4510b.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants