diff --git a/pkg/core/command.go b/pkg/core/command.go index e9e671b..5c1d77c 100644 --- a/pkg/core/command.go +++ b/pkg/core/command.go @@ -1259,27 +1259,27 @@ func (c *Command) NewChildCommandFunction(name string, description string, fn an // if not, panic t := reflect.TypeOf(fn) if t.Kind() != reflect.Func { - panic("NewSubFunction '" + name + "' requires a function with the signature 'func(*struct) error'") + panic("NewChildCommandFunction '" + name + "' requires a function with the signature 'func(*struct) error'") } // Check the function has 1 input ant it's a struct pointer fnValue := reflect.ValueOf(fn) if t.NumIn() != 1 { - panic("NewSubFunction '" + name + "' requires a function with the signature 'func(*struct) error'") + panic("NewChildCommandFunction '" + name + "' requires a function with the signature 'func(*struct) error'") } // Check the input is a struct pointer if t.In(0).Kind() != reflect.Ptr { - panic("NewSubFunction '" + name + "' requires a function with the signature 'func(*struct) error'") + panic("NewChildCommandFunction '" + name + "' requires a function with the signature 'func(*struct) error'") } if t.In(0).Elem().Kind() != reflect.Struct { - panic("NewSubFunction '" + name + "' requires a function with the signature 'func(*struct) error'") + panic("NewChildCommandFunction '" + name + "' requires a function with the signature 'func(*struct) error'") } // Check only 1 output and it's an error if t.NumOut() != 1 { - panic("NewSubFunction '" + name + "' requires a function with the signature 'func(*struct) error'") + panic("NewChildCommandFunction '" + name + "' requires a function with the signature 'func(*struct) error'") } if t.Out(0) != reflect.TypeOf((*error)(nil)).Elem() { - panic("NewSubFunction '" + name + "' requires a function with the signature 'func(*struct) error'") + panic("NewChildCommandFunction '" + name + "' requires a function with the signature 'func(*struct) error'") } flags := reflect.New(t.In(0).Elem()) result.Action(func() error { diff --git a/pkg/core/config.go b/pkg/core/config.go index fba030f..b3ddca0 100644 --- a/pkg/core/config.go +++ b/pkg/core/config.go @@ -37,14 +37,14 @@ func NewConfigVar[T any](val T) ConfigVar[T] { return ConfigVar[T]{val: val, set: true} } -// Cfg holds configuration settings and feature flags. +// Config holds configuration settings and feature flags. type Config struct { mu sync.RWMutex settings map[string]any features map[string]bool } -// NewEtc creates a new configuration store. +// NewConfig creates a new configuration store. func NewConfig() *Config { return &Config{ settings: make(map[string]any), diff --git a/pkg/core/contract.go b/pkg/core/contract.go index b19fe22..522f5be 100644 --- a/pkg/core/contract.go +++ b/pkg/core/contract.go @@ -93,15 +93,15 @@ func New(opts ...Option) (*Core, error) { c := &Core{ app: app, fs: defaultFS, - cfg: NewConfig(), + cfg: &Config{settings: make(map[string]any), features: make(map[string]bool)}, err: &ErrPan{}, log: &ErrLog{&ErrOpts{Log: defaultLog}}, cli: NewCoreCli(app), - srv: NewService(), + srv: &Service{Services: make(map[string]any)}, lock: &Lock{}, - i18n: NewCoreI18n(), + i18n: &I18n{}, } - c.ipc = NewBus(c) + c.ipc = &Ipc{core: c} for _, o := range opts { if err := o(c); err != nil { diff --git a/pkg/core/core.go b/pkg/core/core.go index 1e19b17..a7861fc 100644 --- a/pkg/core/core.go +++ b/pkg/core/core.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: EUPL-1.2 // Package core is a dependency injection and service lifecycle framework for Go. -// This file defines the Core struct, all exported methods, and all With* options. +// This file defines the Core struct, accessors, and IPC/error wrappers. package core diff --git a/pkg/core/embed.go b/pkg/core/embed.go index 4e0addc..259a7dc 100644 --- a/pkg/core/embed.go +++ b/pkg/core/embed.go @@ -2,7 +2,7 @@ // Embedded assets for the Core framework. // -// Emb provides scoped filesystem access for go:embed and any fs.FS. +// Embed provides scoped filesystem access for go:embed and any fs.FS. // Also includes build-time asset packing (AST scanner + compressor) // and template-based directory extraction. // @@ -319,9 +319,9 @@ func getAllFiles(dir string) ([]string, error) { return result, err } -// --- Emb: Scoped Filesystem Mount --- +// --- Embed: Scoped Filesystem Mount --- -// Emb wraps an fs.FS with a basedir for scoped access. +// Embed wraps an fs.FS with a basedir for scoped access. // All paths are relative to basedir. type Embed struct { basedir string @@ -379,7 +379,7 @@ func (s *Embed) ReadString(name string) (string, error) { return string(data), nil } -// Sub returns a new Emb anchored at a subdirectory within this mount. +// Sub returns a new Embed anchored at a subdirectory within this mount. func (s *Embed) Sub(subDir string) (*Embed, error) { sub, err := fs.Sub(s.fsys, s.path(subDir)) if err != nil { @@ -402,7 +402,7 @@ func (s *Embed) EmbedFS() embed.FS { return embed.FS{} } -// BaseDir returns the basedir this Emb is anchored at. +// BaseDir returns the basedir this Embed is anchored at. func (s *Embed) BaseDir() string { return s.basedir } diff --git a/pkg/core/fs.go b/pkg/core/fs.go index 336253f..fcf4e94 100644 --- a/pkg/core/fs.go +++ b/pkg/core/fs.go @@ -254,7 +254,7 @@ func (m *Fs) Delete(p string) error { return err } if full == "/" || full == os.Getenv("HOME") { - return E("local.Delete", "refusing to delete protected path: "+full, nil) + return E("core.Delete", "refusing to delete protected path: "+full, nil) } return os.Remove(full) } @@ -266,7 +266,7 @@ func (m *Fs) DeleteAll(p string) error { return err } if full == "/" || full == os.Getenv("HOME") { - return E("local.DeleteAll", "refusing to delete protected path: "+full, nil) + return E("core.DeleteAll", "refusing to delete protected path: "+full, nil) } return os.RemoveAll(full) } diff --git a/pkg/core/service.go b/pkg/core/service.go index 3479a7a..3b489d4 100644 --- a/pkg/core/service.go +++ b/pkg/core/service.go @@ -17,7 +17,7 @@ type Service struct { locked bool } -// NewSrv creates an empty service registry. +// NewService creates an empty service registry. func NewService() *Service { return &Service{ Services: make(map[string]any),