func getInodeRatio(checkDir string) (ratio float64) {
	defer func() {
		if r := recover(); r != nil {
			log.Printf("Errors encountered, skipping directory scan on %q.", checkDir)
			ratio = 0
		}
	}()
	log.Printf("Determining inode to file count ratio on %q. Please wait, creating %v files...", checkDir,
		*testFileCount)
	var wg sync.WaitGroup
	tempDir, err := ioutil.TempDir(checkDir, testDirName)
	if err != nil {
		log.Print(err)
		return
	}
	defer os.RemoveAll(tempDir)
	signalChan := make(chan os.Signal, 1)
	doneSignalChan := make(chan struct{}, 1)
	registerTempdirSignal(signalChan)
	wg.Add(1)
	go func() {
		defer wg.Done()
		for {
			select {
			case <-signalChan:
				log.Printf("Cleaning up temporary directory %v, please wait...", tempDir)
				os.RemoveAll(tempDir)
				log.Printf("Exiting program as requested.")
				os.Exit(1)
			case <-doneSignalChan:
				return
			}
		}
	}()
	dirSizeEmpty, err := getDirSize(tempDir)
	if err != nil {
		log.Print(err)
		return
	}
	cg := cerrgroup.New(runtime.NumCPU())
	content := []byte(testContent)
	for i := int64(0); i < *testFileCount; i++ {
		cg.Go(func() error {
			t, err := ioutil.TempFile(tempDir, "")
			if err != nil {
				log.Print(err)
				return err
			}
			if _, err := t.Write(content); err != nil {
				log.Print(err)
				return err
			}
			if err := t.Close(); err != nil {
				log.Print(err)
				return err
			}
			return nil
		})
	}
	if err = cg.Wait(); err != nil {
		log.Print(err)
		return
	}
	dirSizeFull, err := getDirSize(tempDir)
	if err != nil {
		log.Print(err)
		return
	}
	if dirSizeFull < (minRatio**testFileCount) || dirSizeFull > (maxRatio**testFileCount) {
		log.Printf("Directory stat st_size structure is most likely incorrect (%v bytes used). Skipping folder checks.",
			dirSizeFull)
		return
	}
	ratio = float64(dirSizeFull-dirSizeEmpty) / float64(*testFileCount)
	if ratio < minRatio || ratio > maxRatio {
		log.Printf("Calculated ratio (%v) failed sanity checking. Skipping folder checks.", ratio)
		ratio = 0
		return
	}
	doneSignalChan <- struct{}{}
	wg.Wait()
	log.Printf("Done. Approximate directory inode size to file count ratio on %q is %v.", checkDir, ratio)
	return
}
getInodeRatio will do a rough estimation on how much a single file occupies in a directory inode.
package main
import (
	"github.com/dkorunic/findlargedir/cerrgroup"
	"io/ioutil"
	"log"
	"os"
	"runtime"
	"sync"
)
const testContent = "Death is lighter than a feather, but Duty is heavier than a mountain."
const minRatio = 1
const maxRatio = 128