> Package path is for *nix paths only. import "path/filepath" instead.

When should path be used?  Or should it be deprecated in favor of path/filepath?

 

John

    John Souvestre - New Orleans LA

 

From: golang-nuts@googlegroups.com [mailto:golang-nuts@googlegroups.com] On 
Behalf Of Jan Mercl
Sent: 2016 June 14, Tue 12:01
To: Tong Sun; golang-nuts
Subject: Re: [go-nuts] How to properly get basename under DOS?

 

Package path is for *nix paths only. import "path/filepath" instead.

 

On Tue, Jun 14, 2016, 18:55 Tong Sun <suntong...@gmail.com> wrote:

I thought to get basename, we should use the official path.Base -- 
https://golang.org/pkg/path/#Base

 

However, I just found out that it is not working under DOS -- 
https://play.golang.org/p/kfr0N50JWc

 

package main


import (
 "fmt"
 "path"
)


func main() {
 fmt.Println(path.Base("/a/b.c"))
 fmt.Println(path.Base(`C:\Program Files\Microsoft Visual Studio 
9\Common7\IDE\devenv.exe`))
}

 

The output is:

 

b.c
C:\Program Files\Microsoft Visual Studio 9\Common7\IDE\devenv.exe

 

What's your solution for this, that is working for both Linux and Windows? 

 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to