Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

He can do a test using `errors.Is(err, syscall.ENOTDIR)`

  func rootInfo(root, p string) (has bool, isDir bool, err error) {
   p = path.Clean(p)
   info, err := os.Stat(root + "/" + p)
   if info != nil {
    has, isDir = true, info.IsDir()
    return
   }
   if errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) {
    err = nil
   }
   return
  }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: