-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·49 lines (39 loc) · 1012 Bytes
/
setup.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
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to install Go
install_go() {
echo "Go is not installed. Installing Go..."
GO_VERSION="1.22"
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi
GO_TAR="go$GO_VERSION.$OS-$ARCH.tar.gz"
GO_URL="https://golang.org/dl/$GO_TAR"
wget $GO_URL
sudo tar -C /usr/local -xzf $GO_TAR
rm $GO_TAR
export PATH=$PATH:/usr/local/go/bin
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
source ~/.profile
}
# Check if Go is installed
if command_exists go; then
echo "Go is already installed."
else
install_go
fi
# Set up project
echo "Setting up the project..."
cd "$(dirname "$0")"
go mod tidy
# Build the project
echo "Building the project..."
go build -o sack ./cmd
echo "Setup complete. You can now run the project with './sack start'"