github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/lib/fsutil/readDirnames.go (about)

     1  package fsutil
     2  
     3  import "os"
     4  
     5  func readDirnames(dirname string, ignoreMissing bool) ([]string, error) {
     6  	if file, err := os.Open(dirname); err != nil {
     7  		if ignoreMissing && os.IsNotExist(err) {
     8  			return nil, nil
     9  		}
    10  		return nil, err
    11  	} else {
    12  		defer file.Close()
    13  		dirnames, err := file.Readdirnames(-1)
    14  		return dirnames, err
    15  	}
    16  }