-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision.sh
70 lines (58 loc) · 1.64 KB
/
provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Update packages
sudo apt update -y && sudo apt upgrade -y
# Install required dependencies
sudo apt install -y \
build-essential \
curl \
git \
htop \
jq \
nano \
tree \
unzip \
vim \
wget \
zip
# Install Go
if ! command -v go &> /dev/null; then
echo "Installing Go..."
# Detect system architecture
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
# Download amd64 version for Linux machines
wget -q "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
go_arch="amd64"
elif [[ "$arch" == "arm64" ]] || [[ "$arch" == "aarch64" ]]; then
# Download arm64 version for Macs M1/M2 and other arm64 architectures
wget -q "https://go.dev/dl/go${GO_VERSION}.linux-arm64.tar.gz"
go_arch="arm64"
else
echo "Unsupported architecture: $arch"
exit 1
fi
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-${go_arch}.tar.gz"
rm "go${GO_VERSION}.linux-${go_arch}.tar.gz"
fi
# Add Go in PATH
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
source /etc/profile
# Configure GOPATH
touch /home/vagrant/.bash_profile
echo "export GOPATH=/home/vagrant/go" >> /home/vagrant/.bash_profile
source /home/vagrant/.bash_profile
mkdir -p "$GOPATH/bin"
# Verify Go installation
go version
# Install useful Go tools
echo "Installing Go tools..."
# Install goimports
go install golang.org/x/tools/cmd/goimports@latest
# Install air
go install github.com/air-verse/air@latest
# Install Delve
go install github.com/go-delve/delve/cmd/dlv@latest
# Install golint
go install golang.org/x/lint/golint@latest
# Install go vet
# go install golang.org/x/tools/cmd/govet@latest