gopkg.in/alecthomas/gometalinter.v3@v3.0.0/_linters/src/golang.org/x/tools/imports/fastwalk_portable.go (about) 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 // +build appengine !linux,!darwin,!freebsd,!openbsd,!netbsd 6 7 package imports 8 9 import ( 10 "io/ioutil" 11 "os" 12 ) 13 14 // readDir calls fn for each directory entry in dirName. 15 // It does not descend into directories or follow symlinks. 16 // If fn returns a non-nil error, readDir returns with that error 17 // immediately. 18 func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error { 19 fis, err := ioutil.ReadDir(dirName) 20 if err != nil { 21 return err 22 } 23 for _, fi := range fis { 24 if err := fn(dirName, fi.Name(), fi.Mode()&os.ModeType); err != nil { 25 return err 26 } 27 } 28 return nil 29 }