Yeah, it seems odd that a golang solution was used instead of just shell.
paths() {
dir=`dirname $1`
while test "$dir" != '/' && test "$dir" != '.' ; do
echo $dir
dir=`dirname $dir`
done
}
find $dir -type f -not -path '*/.git/*' | while read file; do
cnt=`wc -l < $file`
for d in `paths $file`; do
printf "%s\t%s\n" $cnt "$d"
done
done | awk '{
hierarchy[ $2 ] += $1;
}
END {
for (dir in hierarchy) {
printf("%8d %s\n", hierarchy[dir], dir)
}
}' | sort -rn | head | sort -k 2
find dev arch kern uvm -type d | while read dn; do printf "$(find $dn -type f | xargs wc -l | awk 'END {print $1}')\t$(du -h $dn | awk 'END {print $1}')\t${dn}\n"; done
Just kidding, but for smaller repos it gets the job done! And it's easy to run anything on each individual dir and add it to the output on the fly.