master
sh 26 lines 586 Bytes
Raw
1 #!/bin/sh
2
3 # Exit immediately if a command exits with a non-zero status.
4 set -e
5
6 # Optional: Clean slate - remove existing module files
7 test -f "go.mod" && rm -f go.mod
8 test -f "go.sum" && rm -f go.sum
9
10 # 1. Initialize the Go module
11 echo "Initializing Go module..."
12 go mod init server
13
14 # 2. Tidy dependencies
15 echo "Tidying dependencies..."
16 go mod tidy
17
18 # 3. Build the main server executable using '.' for current package
19 echo "Building server executable..."
20 go build -o ./server .
21
22 # 4. Run the unit tests
23 echo "Running unit tests..."
24 go test -v
25
26 echo "Build and test script finished."