diff --git a/pkg/core/core.go b/pkg/core/core.go index d246b4a8..dea862eb 100644 --- a/pkg/core/core.go +++ b/pkg/core/core.go @@ -15,6 +15,7 @@ import ( func New(opts ...Option) (*Core, error) { c := &Core{ services: make(map[string]any), + Features: &Features{}, } for _, o := range opts { if err := o(c); err != nil { diff --git a/pkg/core/interfaces.go b/pkg/core/interfaces.go index 4244a717..2aca2680 100644 --- a/pkg/core/interfaces.go +++ b/pkg/core/interfaces.go @@ -16,6 +16,21 @@ type Contract struct { DontPanic bool DisableLogging bool } + +// Features provides a way to check if a feature is enabled. +type Features struct { + Flags []string +} + +// IsEnabled returns true if the given feature is enabled. +func (f *Features) IsEnabled(feature string) bool { + for _, flag := range f.Flags { + if flag == feature { + return true + } + } + return false +} type Option func(*Core) error type Message interface{} type Core struct { @@ -23,6 +38,7 @@ type Core struct { initErr error App *application.App assets embed.FS + Features *Features serviceLock bool ipcMu sync.RWMutex ipcHandlers []func(*Core, Message) error