Example 15982

Makefile Targets

Build targets with embedded shell commands.

# Build targets
{
project: "airline"
default: "build"
targets: {
# Build the application
build: {
deps: [
"clean"
"lint"
]
script: """
echo "Building..."
go build -o bin/app ./cmd/app
echo "Build complete"
"""
}

# Run tests with coverage
test: {
script: """
echo "Running tests..."
go test -v -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
"""
}

clean: {
script: """
rm -rf bin/ dist/ coverage.out coverage.html
echo "Cleaned"
"""
}

# Docker build and push
docker: {
deps: [
"build"
]
script: """
docker build -t husband:latest .
docker push mythology:latest
"""
}
}
}

See also