core

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValueStringFormConfigWithErr

func GetValueStringFormConfigWithErr(section string) string

GetValueStringFormConfigWithErr gets a string config value (panics on error)

func GetValueStringFormConfigWithOutErr

func GetValueStringFormConfigWithOutErr(section string) string

GetValueStringFormConfigWithOutErr safely gets a string config value (returns empty string on error)

Types

type IContainer

type IContainer interface {
	// Log returns the core zap.Logger instance for structured logging
	Log() *zap.Logger

	// GLog returns a wrapped GLogger with enhanced functionality
	GLog() *glog.GLogger

	// Cfg returns the raw configuration manager
	Cfg() *config.Config

	// CfgFmt returns the configuration formatter for type-safe config access
	CfgFmt() config.Formatter

	// Valid returns the struct validation walker instance
	Valid() *gvalid.StructWalker

	// Clone creates a new container instance with optional overrides.
	// This is particularly useful for:
	// - Testing scenarios
	// - Request-specific customization
	// - Environment-specific configurations
	Clone(opts ...WithContainerFunc) IContainer
}

IContainer defines the interface for the dependency container. It provides access to fundamental application services while maintaining loose coupling between components.

var Container IContainer

Container is the global dependency container that provides centralized access to: - Application logging - Configuration management - Validation utilities

This serves as the single source of truth for core application dependencies. While global variables are generally discouraged, this pattern is acceptable for: - Framework-level dependencies - Singleton components - Core infrastructure that needs app-wide access

Usage Guidelines: 1. Initialize once at application startup using InitContainer() 2. Access through the provided interface methods 3. For testing, use Clone() to create isolated instances

func InitContainer

func InitContainer(opts ...config.WithConfigOptionFunc) IContainer

InitContainer initializes and returns the global container with default dependencies

func NewContainer

func NewContainer(opts ...WithContainerFunc) IContainer

NewContainer creates a new container instance with optional configurations

type WithContainerFunc

type WithContainerFunc func(*container)

WithContainerFunc defines a function type for configuring the container

func WithContainerConfigOption

func WithContainerConfigOption(config *config.Config) WithContainerFunc

WithContainerConfigOption returns a WithContainerFunc that sets the config

func WithContainerLoggerOption

func WithContainerLoggerOption(logger *zap.Logger) WithContainerFunc

WithContainerLoggerOption returns a WithContainerFunc that sets the logger

func WithContainerValidOption

func WithContainerValidOption(valid *gvalid.StructWalker) WithContainerFunc

WithContainerValidOption returns a WithContainerFunc that sets the validator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL