From 4b8e83a60edac88d5c44744ecc4cc5c923ba2707 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Thu, 29 Feb 2024 15:05:48 -0800 Subject: [PATCH] Add go_deps function to get dependnecies from go.mod --- dot_config/profile/profile.d/functions.sh.tmpl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dot_config/profile/profile.d/functions.sh.tmpl b/dot_config/profile/profile.d/functions.sh.tmpl index 8920c99..3aca6b4 100644 --- a/dot_config/profile/profile.d/functions.sh.tmpl +++ b/dot_config/profile/profile.d/functions.sh.tmpl @@ -20,6 +20,13 @@ make_scripts() ( done ) +go_deps() ( + GO_MOD=${1:-go.mod} + START_AT=$(grep -n '^require ($' "${GO_MOD}" | awk -F : '{print $1}' | head -n 1) + END_AT=$(grep -n '^)$' "${GO_MOD}" | awk -F : '{print $1}' | head -n 1) + awk 'NR>'"${START_AT}"' && NR<'"${END_AT}"' {print $1}' "${GO_MOD}" +) + make_script() ( cat <<-EOF > "${1}" #!/usr/bin/env bash