Automated Action 887703b6a2 Add Go Todo App implementation
This commit adds a complete Go implementation of the Todo application. The
application uses Gin framework for the web server, GORM for database access,
and SQLite for storage.

Key features:
- Todo CRUD operations with the same API endpoints
- Health check endpoint
- Database migrations
- Tests for models, services, and API handlers
- Documentation for the API
- Configurable settings
2025-05-17 22:20:05 +00:00

42 lines
1.0 KiB
Go

package main
import (
"fmt"
"log"
"path/filepath"
"github.com/simpletodoapp/go-todo-app/internal/api"
"github.com/simpletodoapp/go-todo-app/internal/config"
"github.com/simpletodoapp/go-todo-app/internal/database"
)
func main() {
// Load configuration
cfg, err := config.LoadConfig()
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
// Connect to database
db, err := database.NewDatabase(cfg)
if err != nil {
log.Fatalf("Failed to initialize database: %v", err)
}
// Run migrations
migrationRunner := database.NewMigrationRunner(db, cfg)
migrationsPath := filepath.Join(".", "migrations")
if err := migrationRunner.RunMigrations(migrationsPath); err != nil {
log.Fatalf("Failed to run migrations: %v", err)
}
// Setup router
router := api.SetupRouter(cfg, db)
// Start server
serverAddr := fmt.Sprintf(":%s", cfg.ServerPort)
log.Printf("Starting server on %s", serverAddr)
if err := router.Run(serverAddr); err != nil {
log.Fatalf("Failed to start server: %v", err)
}
}