.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / internal / fastwalk / fastwalk_portable.go
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build appengine || (!linux && !darwin && !freebsd && !openbsd && !netbsd)
6 // +build appengine !linux,!darwin,!freebsd,!openbsd,!netbsd
7
8 package fastwalk
9
10 import (
11         "io/ioutil"
12         "os"
13 )
14
15 // readDir calls fn for each directory entry in dirName.
16 // It does not descend into directories or follow symlinks.
17 // If fn returns a non-nil error, readDir returns with that error
18 // immediately.
19 func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error {
20         fis, err := ioutil.ReadDir(dirName)
21         if err != nil {
22                 return err
23         }
24         skipFiles := false
25         for _, fi := range fis {
26                 if fi.Mode().IsRegular() && skipFiles {
27                         continue
28                 }
29                 if err := fn(dirName, fi.Name(), fi.Mode()&os.ModeType); err != nil {
30                         if err == ErrSkipFiles {
31                                 skipFiles = true
32                                 continue
33                         }
34                         return err
35                 }
36         }
37         return nil
38 }