Handle Go bootstrap during process deploy

This commit is contained in:
Haitao Pan 2026-03-15 16:59:43 +08:00
parent 7a5e9fda08
commit d1f10e2170
2 changed files with 20 additions and 5 deletions

View File

@ -3,6 +3,17 @@ set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh" source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh"
apt_install() {
if command -v sudo >/dev/null 2>&1 && [[ "${EUID}" -ne 0 ]]; then
sudo apt-get update
sudo apt-get install -y golang
return
fi
apt-get update
apt-get install -y golang
}
if [ ! -f go.mod ]; then if [ ! -f go.mod ]; then
echo ">>> go.mod not found, initializing module" echo ">>> go.mod not found, initializing module"
go mod init account go mod init account
@ -17,8 +28,7 @@ if ! command -v go >/dev/null; then
brew install go@1.24 brew install go@1.24
brew link --overwrite --force go@1.24 brew link --overwrite --force go@1.24
else else
sudo apt-get update apt_install
sudo apt-get install -y golang
fi fi
fi fi

View File

@ -135,9 +135,14 @@ case "$MODE" in
fi fi
if [[ -f "go.mod" ]]; then if [[ -f "go.mod" ]]; then
need_cmd go if command -v go >/dev/null 2>&1; then
log "downloading Go dependencies (go mod download)" log "downloading Go dependencies (go mod download)"
go mod download go mod download
elif [[ "${ACTION}" == "deploy" ]]; then
log "go not found; process deploy will install it during scripts/install-process.sh"
else
need_cmd go
fi
did_any=true did_any=true
fi fi
;; ;;