1
0
mirror of https://github.com/MADTeacher/go_basics.git synced 2025-11-23 21:34:47 +02:00
Files
go_basics/part_5/5.2/10.go
2025-06-14 12:40:10 +03:00

27 lines
409 B
Go

package main
import (
"fmt"
"io/fs"
"path/filepath"
)
func main() {
countDirs := 0
countFiles := 0
filepath.WalkDir("C:\\Go", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if !d.IsDir() {
countFiles++
} else {
countDirs++
}
return nil
})
fmt.Printf("Amount of files: %d\n", countFiles)
fmt.Printf("Amount of directories: %d\n", countDirs)
}