- Fix error return value checks (errcheck) - Fix unused parameters by using underscore prefix - Add missing package comments to all packages - Fix context key type issue in middleware (use typed contextKey) - Replace deprecated trace.NewNoopTracerProvider with noop.NewTracerProvider - Fix embedded field selector in database client - Remove trailing whitespace - Remove revive linter (as requested) to avoid stuttering warnings for public API interfaces All linting and formatting checks now pass.
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
// Package main provides the application entry point for the Go Platform.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.dcentral.systems/toolz/goplt/internal/di"
|
|
"git.dcentral.systems/toolz/goplt/internal/infra/database"
|
|
"git.dcentral.systems/toolz/goplt/internal/server"
|
|
"git.dcentral.systems/toolz/goplt/pkg/logger"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
func main() {
|
|
// Create DI container with lifecycle hooks
|
|
// We need to invoke the HTTP server to ensure all providers execute
|
|
container := di.NewContainer(
|
|
// Invoke lifecycle hooks
|
|
fx.Invoke(di.RegisterLifecycleHooks),
|
|
// Force HTTP server to be created (which triggers all dependencies)
|
|
// This ensures database, health, metrics, etc. are all created
|
|
fx.Invoke(func(_ *server.Server, _ *database.Client) {
|
|
// Both server and database are created, hooks are registered
|
|
// This ensures all providers execute
|
|
}),
|
|
)
|
|
|
|
// Create root context
|
|
ctx := context.Background()
|
|
|
|
// Start the application
|
|
if err := container.Start(ctx); err != nil {
|
|
log := logger.GetGlobalLogger()
|
|
if log != nil {
|
|
log.Error("Failed to start application",
|
|
logger.Error(err),
|
|
)
|
|
} else {
|
|
fmt.Fprintf(os.Stderr, "Failed to start application: %v\n", err)
|
|
}
|
|
os.Exit(1)
|
|
}
|
|
}
|