From 0c3321bfabc2c6a499d76f1d5fce2a436101a069 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 2 Nov 2025 03:03:54 +0000 Subject: [PATCH] feat: Add feature system to Core (#17) This commit introduces a new feature system to the Core struct. A new `Features` struct is defined in `pkg/core/interfaces.go` with an `IsEnabled` method to check if a feature is enabled. The `Core` struct is updated to include this new `Features` struct, which is initialized in the `New` function. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- pkg/core/core.go | 1 + pkg/core/interfaces.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) 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