# shellcheck shell=bash
function _build_find_exclude() {
    local find_exclude
    excluded_dirs+=" vendor .git .trash-cache bin"

    for dir in $excluded_dirs; do
        find_exclude+=" -path ./$dir -prune -o"
    done

    echo "${find_exclude}"
}

function _find_pkg_dirs() {
    # shellcheck disable=SC2046
    find . $(_build_find_exclude) -path "$1" -printf "%h\n" | sort -u
}

function find_modules() {
    # shellcheck disable=SC2046
    find . $(_build_find_exclude) -name go.mod -printf "%h\n" | sort -u
}

function find_unit_test_dirs() {
    local excluded_dirs="${*}"
    _find_pkg_dirs "./*/*_test.go"
}
