Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Empty-directory/Go/empty-directory.go
Normal file
27
Task/Empty-directory/Go/empty-directory.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
empty, err := IsEmptyDir("/tmp")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
if empty {
|
||||
fmt.Printf("/tmp is empty\n")
|
||||
} else {
|
||||
fmt.Printf("/tmp is not empty\n")
|
||||
}
|
||||
}
|
||||
|
||||
func IsEmptyDir(name string) (bool, error) {
|
||||
entries, err := ioutil.ReadDir(name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return len(entries) == 0, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue