douxian6008 2015-10-02 13:29
浏览 311
已采纳

FileInfo.IsDir()未检测到目录

I have some code that walks through a directory to get the files, to operate on them and it uses IsDir() to skip directories. However, a directory isn't properly being detected:

err = filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
    if !f.IsDir() {
        fileList = append(fileList, path)
    }
    return nil
})

Error:

Put app/javascripts: read public/app/javascripts: is a directory

I'm on OSX. Here's the directory listing:

drwxr-xr-x@   6 me  staff     204 Sep 25 11:28 javascripts

Is there a better way to detect directories?

  • 写回答

2条回答 默认 最新

  • douzhuo3233 2015-10-02 14:14
    关注

    I was looking at the wrong dir (confusing names). It was a symlink, which makes sense.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?