21 lines
591 B
Bash
21 lines
591 B
Bash
#!/bin/bash
|
|
|
|
if [ ! -f go.mod ]; then
|
|
echo "go.mod not found in current directory"
|
|
exit 1
|
|
fi
|
|
|
|
# Проверяем, изменились ли зависимости
|
|
if [ ! -f go.sum ] || ! go mod verify >/dev/null 2>&1; then
|
|
echo "Dependencies changed, downloading..."
|
|
go mod download
|
|
fi
|
|
|
|
# Собираем для указанной платформы
|
|
if [ -n "$1" ] && [ -n "$2" ]; then
|
|
echo "Building for $1 $2..."
|
|
GOOS=$1 GOARCH=$2 go build -o "bin/hello-api-$1-$2" main.go
|
|
else
|
|
echo "Building for current platform..."
|
|
go build -o bin/hello-api main.go
|
|
fi |