package config import ( "git.0x7f.app/WOJ/woj-server/internal/model" "git.0x7f.app/WOJ/woj-server/pkg/file" "github.com/samber/do" "github.com/urfave/cli/v2" "gopkg.in/yaml.v3" "log" ) var _ Service = (*service)(nil) type Service interface { GetConfig() *model.Config HealthCheck() error } func NewService(i *do.Injector) (Service, error) { cliCtx := do.MustInvoke[*cli.Context](i) data, err := file.Read(cliCtx.String("config")) if err != nil { log.Printf("Failed to setup config: %s\n", err.Error()) return nil, err } srv := &service{} err = yaml.Unmarshal(data, &srv.conf) if err != nil { log.Printf("Failed to setup config: %s\n", err.Error()) return nil, err } return srv, nil } type service struct { conf model.Config } func (s *service) GetConfig() *model.Config { return &s.conf } func (s *service) HealthCheck() error { return nil }