Re: [go-nuts] path.Dir() bug on Windows

731 views
Skip to first unread message

David Symonds

unread,
Aug 4, 2012, 8:51:22 PM8/4/12
to Adrien, golan...@googlegroups.com
The path package is for /-separated paths. If you want to manipulate
filesystem paths use the path/filepath package.


Dave.

Adrien

unread,
Aug 5, 2012, 6:56:04 AM8/5/12
to golan...@googlegroups.com
Oh, OK, I see, thanks for your reply.
Why the choice to separate these two kinds of paths has been made?
Should we use path package only for URL, or something like that?

On Saturday, August 4, 2012 5:04:18 PM UTC+1, Adrien wrote:
Hi all,

Just to inform you that the function path.Dir() always returns "." with a Windows path formated like this: C:\Users\MyPath

It's probably because, in the file /src/pkg/path/path.go, the used separator for all functions is '/' and not uint8(os.PathSeparator).

When we try to open a file with our program on Windows, the retrieved path is formated with '\' separators: because of that, we don't have the expected result...

I think this issue is easy to fix (we just need to use os.PathSeparator instead of "/").

Cheers,

Adrien


Russ Cox

unread,
Aug 9, 2012, 7:40:47 PM8/9/12
to Adrien, golan...@googlegroups.com
On Sun, Aug 5, 2012 at 6:56 AM, Adrien <adrien...@marakana.com> wrote:
> Oh, OK, I see, thanks for your reply.
> Why the choice to separate these two kinds of paths has been made?
> Should we use path package only for URL, or something like that?

Yes, URLs or any other software system that uses slash-separated paths
as an abstraction.

Russ
Reply all
Reply to author
Forward
0 new messages