From 7d3da1bf2ea91e98ebfdc5ecf2112c8a0bb56420 Mon Sep 17 00:00:00 2001 From: furu04 Date: Wed, 31 Dec 2025 18:10:15 +0900 Subject: [PATCH] fix .gitignore --- .gitignore | 4 ++-- cmd/server/main.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 cmd/server/main.go diff --git a/.gitignore b/.gitignore index b3d1215..596dd44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Binaries -homework-manager +/homework-manager homework-manager.exe -server +/server server.exe *.exe *.dll diff --git a/cmd/server/main.go b/cmd/server/main.go new file mode 100644 index 0000000..9b24a0f --- /dev/null +++ b/cmd/server/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "flag" + "log" + + "homework-manager/internal/config" + "homework-manager/internal/database" + "homework-manager/internal/router" +) + +func main() { + // Parse command line flags + configPath := flag.String("config", "", "Path to config.ini file (default: config.ini in current directory)") + flag.Parse() + + // Load configuration + cfg := config.Load(*configPath) + + // Connect to database + log.Printf("Connecting to database (driver: %s)", cfg.Database.Driver) + if err := database.Connect(cfg.Database, cfg.Debug); err != nil { + log.Fatalf("Failed to connect to database: %v", err) + } + + // Run migrations + if err := database.Migrate(); err != nil { + log.Fatalf("Failed to run migrations: %v", err) + } + + // Setup router + r := router.Setup(cfg) + + // Start server + log.Printf("Server starting on http://localhost:%s", cfg.Port) + if err := r.Run(":" + cfg.Port); err != nil { + log.Fatalf("Failed to start server: %v", err) + } +}