-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
50 lines (42 loc) · 1.28 KB
/
setup.sh
File metadata and controls
50 lines (42 loc) · 1.28 KB
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
#!/bin/bash
# E-Commerce API Setup Script
echo "🚀 Setting up E-Commerce API..."
# Check if Go is installed
if ! command -v go &> /dev/null; then
echo "❌ Go is not installed. Please install Go 1.23 or later."
exit 1
fi
echo "✅ Go version: $(go version)"
# Check if .env exists
if [ ! -f .env ]; then
echo "📝 Creating .env file from .env.example..."
cp .env.example .env
echo "⚠️ Please edit .env file with your configuration before running the app"
else
echo "✅ .env file already exists"
fi
# Download dependencies
echo "📦 Downloading dependencies..."
go mod download
if [ $? -eq 0 ]; then
echo "✅ Dependencies downloaded successfully"
else
echo "❌ Failed to download dependencies"
exit 1
fi
# Tidy up go.mod
echo "🧹 Tidying up dependencies..."
go mod tidy
echo ""
echo "✨ Setup complete!"
echo ""
echo "Next steps:"
echo "1. Edit .env file with your database credentials"
echo "2. Generate a secure JWT_SECRET (at least 32 characters)"
echo "3. Create your database (e.g., CREATE DATABASE gocommerce;)"
echo "4. Run the application: go run cmd/api/main.go"
echo ""
echo "Optional: Set SEED_DB=true in .env to seed sample data"
echo ""
echo "API will be available at: http://localhost:8080"
echo "Health check: http://localhost:8080/health"