KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'd like to use path.Dir() on Unix and Windows with a platform specific directory. Please take a look at the code: package main import ( "fmt" "path" ) func main() { fmt.Println(`path.Dir("a/b/c"): `, path.Dir("a/b/c")) fmt.Println(`path.Dir("c:\foo\bar.exe"): `, path.Dir(`c:\foo\bar.exe`)) } This outputs path.Dir("a/b/c"): a/b path.Dir("c:\foo\bar.exe"): . I'd like to get for the second call to path.Dir() (windows) something like c:\foo Is it possible to tell path.dir() to use Windows separators for my program running on windows? Or should I always convert the backslashes \ to forward slashes ( / )? What is the preferred strategy here?
Tags (comma-separated)
Save Edits
Cancel