Go server draft
This commit is contained in:
parent
51faa74cd8
commit
29d5885b67
7 changed files with 148 additions and 0 deletions
50
backend/Makefile
Normal file
50
backend/Makefile
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Go parameters
|
||||
GOCMD = go
|
||||
GOBUILD = $(GOCMD) build
|
||||
GOCLEAN = $(GOCMD) clean
|
||||
GOTEST = $(GOCMD) test
|
||||
GOGET = $(GOCMD) get
|
||||
|
||||
# SQLite database filename
|
||||
DB_FILE = db.sqlite3
|
||||
|
||||
# Directory containing migration SQL scripts
|
||||
MIGRATIONS_DIR = migrations
|
||||
|
||||
# Build target
|
||||
build:
|
||||
$(GOBUILD) -o bin/server cmd/*.go
|
||||
|
||||
# Run target
|
||||
run: build
|
||||
./bin/server
|
||||
|
||||
# Clean target
|
||||
clean:
|
||||
$(GOCLEAN)
|
||||
rm -f bin/server
|
||||
rm -f db.sqlite3
|
||||
|
||||
# Test target
|
||||
test:
|
||||
$(GOTEST) ./...
|
||||
|
||||
# Get dependencies target
|
||||
deps:
|
||||
$(GOGET) -v ./...
|
||||
|
||||
# Update dependencies target
|
||||
update:
|
||||
$(GOGET) -u -v ./...
|
||||
$(GOCMD) mod tidy
|
||||
|
||||
# Migration target
|
||||
migrate:
|
||||
@echo "Migrating database $(DB_FILE) using SQL scripts in $(MIGRATIONS_DIR)"
|
||||
@for file in $(wildcard $(MIGRATIONS_DIR)/*.sql); do \
|
||||
echo "Applying migration: $$file"; \
|
||||
sqlite3 $(DB_FILE) < $$file; \
|
||||
done
|
||||
|
||||
# Default target
|
||||
default: build
|
Loading…
Add table
Add a link
Reference in a new issue