func printPath(processPath *string) {
	if processPath != nil && *processPath != "" {
		log.Printf("Last processed path was: %q.", *processPath)
	}
}
printPath will display path processing progress.
package main
import (
	"fmt"
	"github.com/karrick/godirwalk"
	"github.com/pborman/getopt/v2"
	"log"
	"math"
	"os"
	"path/filepath"
	"sync"
	"time"
)
const testDirName = "findlargedir"
const defaultAlertThreshold = 50000
const defaultTestFileCount = 20000
const defaultProgressTicker = time.Minute * 5
const defaultPathnameQueueSize = 1024
var alertThreshold, testFileCount *int64
var helpFlag, accurateFlag, progressFlag, isilonFlag, cloexecFlag, oneFilesystemFlag *bool
func init() {
	alertThreshold = getopt.Int64Long("threshold", 't', defaultAlertThreshold,
		fmt.Sprintf("set file count threshold for alerting (default %v)", defaultAlertThreshold))
	testFileCount = getopt.Int64Long("testcount", 'c', defaultTestFileCount,
		fmt.Sprintf("set initial file count for inode size testing phase (default %v)", defaultTestFileCount))
	helpFlag = getopt.BoolLong("help", 'h', "display help")
	accurateFlag = getopt.BoolLong("accurate", 'a', "full accuracy when checking large directories")
	progressFlag = getopt.BoolLong("progress", 'p', "display progress status every 5 minutes")
	isilonFlag = getopt.BoolLong("isilon", '7', "enable support for EMC Isilon OneFS 7.x")
	cloexecFlag = getopt.BoolLong("cloexec", 'x', "disable open O_CLOEXEC for really ancient Unix systems")
	oneFilesystemFlag = getopt.BoolLong("onefilesystem", 'o', "never cross filesystem boundaries")
}
func main() {
	getopt.Parse()
	args := getopt.Args()
	if *helpFlag || len(args) < 1 {
		getopt.PrintUsage(os.Stderr)
		os.Exit(0)
	}
	log.Printf("Note: program will attempt to identify directories larger than %v entries. Make sure you have r/w privileges.",
		*alertThreshold)
	if *cloexecFlag {
		patchSyscallOpen()
	}
	if *isilonFlag {
		patchSyscallStat()
		patchSyscallLstat()
	}
	for i := range args {
		processDirectory(filepath.Clean(args[i]))
	}
}
func processDirectory(rootPath string) {
	ratio := getInodeRatio(rootPath)
	if ratio <= 0 {
		log.Printf("Unable to calculate inode to file count ratio on %q. Skipping.", rootPath)
		return
	}
	rootStat, err := os.Lstat(rootPath)
	if err != nil {
		log.Print(err)
		return
	}
	var wg sync.WaitGroup
	var lastPathname *string
	signalChan := make(chan os.Signal, 1)
	signalTermChan := make(chan os.Signal, 1)
	doneSignalChan := make(chan struct{}, 1)
	defer close(doneSignalChan)
	registerStatusSignal(signalChan, signalTermChan)
	wg.Add(1)
	go func() {
		defer wg.Done()
		for {
			select {
			case <-signalChan:
				printPath(lastPathname)
			case <-signalTermChan:
				printPath(lastPathname)
				log.Printf("Exiting program as requested.")
				os.Exit(1)
			case <-doneSignalChan:
				return
			}
		}
	}()
	var ticker *time.Ticker
	doneTickerChan := make(chan struct{}, 1)
	defer close(doneTickerChan)
	if *progressFlag {
		ticker = time.NewTicker(defaultProgressTicker)
		wg.Add(1)
		go func() {
			defer wg.Done()
			for {
				select {
				case <-ticker.C:
					printPath(lastPathname)
				case <-doneTickerChan:
					ticker.Stop()
					return
				}
			}
		}()
	}
	accurateChan := make(chan string, defaultPathnameQueueSize)
	if *accurateFlag {
		wg.Add(1)
		go func() {
			defer wg.Done()
			for v := range accurateChan {
				deChildren, err := godirwalk.ReadDirents(v, nil)
				if err != nil {
					log.Print(err)
					continue
				}
				log.Printf("Correct enumeration: directory %q has exactly %v entries.", v, len(deChildren))
			}
		}()
	}
	var offenderTotal, countFromStat int64
	_ = godirwalk.Walk(rootPath, &godirwalk.Options{
		Unsorted:            true,
		FollowSymbolicLinks: false,
		Callback: func(osPathname string, de *godirwalk.Dirent) error {
			if de.IsDir() {
				lastPathname = &osPathname
				fi, err := os.Stat(osPathname)
				if err != nil {
					return err
				}
				if *oneFilesystemFlag && !isSameFilesystem(rootStat, fi) {
					log.Printf("Directory %q is a mount point, skipping further checks.", osPathname)
					return fmt.Errorf("directory %q is a mount point", osPathname)
				}
				countFromStat = int64(float64(fi.Size()) / ratio)
				if countFromStat >= int64(*alertThreshold) {
					log.Printf("Directory %q is possibly a large directory with %v entries.", osPathname,
						humanPrint(countFromStat))
					offenderTotal++
					if *accurateFlag {
						accurateChan <- osPathname
					}
					return fmt.Errorf("directory %q is too large to process", osPathname)
				}
			}
			return nil
		},
		ErrorCallback: func(osPathname string, err error) godirwalk.ErrorAction {
			return godirwalk.SkipNode
		},
	})
	if *progressFlag {
		doneTickerChan <- struct{}{}
	}
	doneSignalChan <- struct{}{}
	close(accurateChan)
	wg.Wait()
	log.Printf("Found %v large directories in %q.", offenderTotal, rootPath)
}
func humanPrint(input int64) string {
	exp := math.Round(math.Log(float64(input)) / math.Log(float64(10)))
	switch {
	case exp >= 10:
		return "~10b"
	case exp >= 9:
		return "~1b"
	case exp >= 8:
		return "~100m"
	case exp >= 7:
		return "~10m"
	case exp >= 6:
		return "~1m"
	case exp >= 5:
		return "~100k"
	case exp >= 4:
		return "~10k"
	case exp >= 3:
		return "~1k"
	}
	return "<1k"
}