21 lines
271 B
Go
21 lines
271 B
Go
package fileutils
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
func IsDirEmpty(dir string) (isEmpty bool, err error) {
|
|
dirFile, err := os.Open(dir)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
_, readErr := dirFile.Readdirnames(1)
|
|
if readErr != nil {
|
|
isEmpty = true
|
|
} else {
|
|
isEmpty = false
|
|
}
|
|
return
|
|
}
|