2013-03-29 18:26 阅读 72


I have a file which gives me back, no such file or directory. Is there a function which can escape a file name for getting the correct path to it? Something similar to the net package QueryEscape ?, but for file paths of course

Here is the Path name "Music/3OH!3 - Streets Of Gold 2010 [Cov+CD][Bubanee]/06. Touchin On My - 30H!3.mp3"

I'm just using a simple

srcName := "Music/3OH!3 - Streets Of Gold 2010 [Cov+CD][Bubanee]/06. Touchin On My - 30H!3.mp3"
src, err := os.Open(srcName)
if err != nil {

The file does exist btw, go just cant follow the path name. The path that bash can follow is Music/3OH\!3\ -\ Streets\ Of\ Gold\ \[Cov+CD\]\[Bubanee\]/12.\ Strrets\ Of\ Gold\ -\ 30H\!3.mp3 which shows all the escaping that is needed.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dqtu14636 dqtu14636 2013-03-29 18:44

    I tried creating the same directory structure on my machine (Mac OS 10.8.3), and I had no trouble opening the file using your code. This means that the path is properly escaped when opening already.

    Make sure you're running your go program from a location right above the Music/ folder, or just use the full root path for srcName.

    点赞 评论 复制链接分享