@@ -116,52 +116,35 @@ clean_dev_python() {
116116}
117117# Go build/module caches.
118118clean_dev_go () {
119- if command -v go > /dev/null 2>&1 ; then
120- # Get Go cache paths
121- local go_build_cache
122- local go_mod_cache
123- go_build_cache=$( go env GOCACHE 2> /dev/null || echo " $HOME /Library/Caches/go-build" )
124- go_mod_cache=$( go env GOMODCACHE 2> /dev/null || echo " $HOME /go/pkg/mod" )
125-
126- # Check if Go caches are whitelisted
127- local build_protected=false
128- local mod_protected=false
129-
130- if is_path_whitelisted " $go_build_cache " ; then
131- build_protected=true
132- fi
119+ command -v go > /dev/null 2>&1 || return 0
133120
134- if is_path_whitelisted " $ go_mod_cache" ; then
135- mod_protected=true
136- fi
121+ local go_build_cache go_mod_cache
122+ go_build_cache= $( go env GOCACHE 2> /dev/null || echo " $HOME /Library/Caches/go-build " )
123+ go_mod_cache= $( go env GOMODCACHE 2> /dev/null || echo " $HOME /go/pkg/mod " )
137124
138- # Only clean if not protected by whitelist
139- if [[ " $build_protected " == " true" && " $mod_protected " == " true" ]]; then
140- if [[ " $DRY_RUN " == " true" ]]; then
141- echo -e " ${YELLOW}${ICON_DRY_RUN}${NC} Go cache · would skip (whitelist)"
142- else
143- echo -e " ${BLUE}${ICON_SKIP}${NC} Go cache · protected by whitelist"
144- fi
145- elif [[ " $build_protected " == " true" ]]; then
146- # Only clean module cache
147- clean_tool_cache " Go module cache" bash -c ' go clean -modcache > /dev/null 2>&1 || true'
148- if [[ " $DRY_RUN " != " true" ]]; then
149- echo -e " ${BLUE}${ICON_SKIP}${NC} Go build cache · protected by whitelist"
150- fi
151- note_activity
152- elif [[ " $mod_protected " == " true" ]]; then
153- # Only clean build cache
154- clean_tool_cache " Go build cache" bash -c ' go clean -cache > /dev/null 2>&1 || true'
155- if [[ " $DRY_RUN " != " true" ]]; then
156- echo -e " ${BLUE}${ICON_SKIP}${NC} Go module cache · protected by whitelist"
157- fi
158- note_activity
125+ local build_protected=false mod_protected=false
126+ is_path_whitelisted " $go_build_cache " && build_protected=true
127+ is_path_whitelisted " $go_mod_cache " && mod_protected=true
128+
129+ if [[ " $build_protected " == " true" && " $mod_protected " == " true" ]]; then
130+ if [[ " $DRY_RUN " == " true" ]]; then
131+ echo -e " ${YELLOW}${ICON_DRY_RUN}${NC} Go cache · would skip (whitelist)"
159132 else
160- # Clean both caches
161- clean_tool_cache " Go cache" bash -c ' go clean -modcache > /dev/null 2>&1 || true; go clean -cache > /dev/null 2>&1 || true'
162- note_activity
133+ echo -e " ${GREEN}${ICON_SUCCESS}${NC} Go cache · skipped (whitelist)"
163134 fi
135+ return 0
164136 fi
137+
138+ if [[ " $build_protected " != " true" && " $mod_protected " != " true" ]]; then
139+ clean_tool_cache " Go cache" bash -c ' go clean -modcache > /dev/null 2>&1 || true; go clean -cache > /dev/null 2>&1 || true'
140+ elif [[ " $build_protected " == " true" ]]; then
141+ clean_tool_cache " Go module cache" bash -c ' go clean -modcache > /dev/null 2>&1 || true'
142+ echo -e " ${GREEN}${ICON_SUCCESS}${NC} Go build cache · skipped (whitelist)"
143+ else
144+ clean_tool_cache " Go build cache" bash -c ' go clean -cache > /dev/null 2>&1 || true'
145+ echo -e " ${GREEN}${ICON_SUCCESS}${NC} Go module cache · skipped (whitelist)"
146+ fi
147+ note_activity
165148}
166149# Rust/cargo caches.
167150clean_dev_rust () {
0 commit comments