Skip to content

Instantly share code, notes, and snippets.

@Ramko9999
Created April 25, 2021 21:24
Show Gist options
  • Save Ramko9999/d49a3f944a6530c099367395f9dace68 to your computer and use it in GitHub Desktop.
Save Ramko9999/d49a3f944a6530c099367395f9dace68 to your computer and use it in GitHub Desktop.
import (
"fmt"
"io/fs"
"path/filepath"
)
// example of counting all files in a root directory
func countFiles() int {
count := 0;
filepath.WalkDir(".", func(path string, file fs.DirEntry, err error) error {
if err != nil {
return err
}
if !file.IsDir() {
fmt.Println(path);
count++;
}
return nil;
});
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment