accounts/scripts/init-go.sh

29 lines
596 B
Bash
Raw Permalink Normal View History

2026-01-24 22:36:29 +08:00
#!/usr/bin/env bash
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh"
if [ ! -f go.mod ]; then
echo ">>> go.mod not found, initializing module"
go mod init account
fi
go mod tidy
echo ">>> 检查 Go 环境"
if ! command -v go >/dev/null; then
echo "未安装 Go自动安装中..."
if [ "${OS:-}" = "Darwin" ]; then
brew install go@1.24
brew link --overwrite --force go@1.24
else
sudo apt-get update
sudo apt-get install -y golang
fi
fi
echo ">>> 配置 Go Proxy"
2026-01-24 22:42:40 +08:00
go env -w GOPROXY=https://proxy.golang.org,direct
2026-01-24 22:36:29 +08:00
go mod tidy