3 ms·
but how would you do that otherwise? Genuinely curious cause I looked up both the go docs and source (disclaimer: not a go dev), and there doesn't seem a way to
by shirogane86x 9mo ago
but how would you do that otherwise? Genuinely curious cause I looked up both the go docs and source (disclaimer: not a go dev), and there doesn't seem a way to handle that specific kind of error through stuff like `errors.Is`, at least from what I can tell, at least in the os and fs packages
- benrazdev 9mo agoFrom what the comments are saying I think you downcast with `errors.As` and then work on the underlying error type. But I don't know for sure.
- deleted 9mo ago[deleted]
- lenkite 9mo agoHe 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 }