Skip to main content
Remy DI - Dependency Injection for Go
GitHub Go Docs Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

v1.9.0

Breaking Changes

  • Function Naming Convention: All retrieve functions now follow a consistent naming pattern:
    • Functions without prefix (Get, GetAll, GetWithPairs, GetWith) now return (T, error)
    • Functions with Must* prefix (MustGet, MustGetAll, MustGetWithPairs, MustGetWith) panic on error
    • Functions with Maybe* prefix (MaybeGet, MaybeGetAll, MaybeGetWithPairs, MaybeGetWith) return zero value on error
  • Renamed Functions:
    • DoGetGet (now returns error)
    • DoGetAllGetAll (now returns error)
    • DoGetGenGetGenGetWithPairs (now returns error)
    • DoGetGenFuncGetGenFuncGetWith (now returns error)
    • Old Get (ignored error) → MustGet (panics on error)
    • Old GetAll (ignored error) → MustGetAll (panics on error)
    • Old GetGen (ignored error) → MustGetGenMustGetWithPairs (panics on error)
    • Old GetGenFunc (ignored error) → MustGetGenFuncMustGetWith (panics on error)
  • Parameter Naming: Changed keys ...string to optTag ...string throughout the codebase for better clarity
  • DependencyRetriever Interface:
    • Replaced Get and GetNamed methods with unified RetrieveBind(bindKey BindKey, tag string) (any, error) method
    • Changed from ValuesGetter[any] to AllValuesGetter[any] interface
  • InstancePair struct changes:
    • Field Key (string) renamed to Tag (string) for better clarity
    • New optional field Key (BindKey) added to allow providing a BindKey directly

Added

  • New Maybe* functions for graceful error handling:
    • MaybeGet, MaybeGetAll, MaybeGetWithPairs, MaybeGetWith
  • Deprecated functions wrapper file (remy_deprecated.go) for backward compatibility (requires build tag remy_keep_deprecated)
  • NewBindKey function: Added NewBindKey[T any]() BindKey function to create a BindKey directly for a given type. This enables using GetWithPairs with explicit BindKey even when reflection is disabled
  • BindOptions exposed: BindOptions type is now exposed at the top-level remy package for use in custom injector implementations
    • Contains Tag field for named bindings
    • Contains SoftOverride field (renamed from ExpectOverride) to allow soft overrides without errors
  • New error types: Refactored error handling with structured error types:
    • ErrConfigNotAllowReturnAll: Returned when trying to use GetAll without DuckTypeElements config enabled
    • ErrGetElementTypeRequiresReflectionEnabled: Returned when trying to get element type from runtime value without reflection enabled
    • All errors now implement proper error wrapping and can be checked with errors.Is()

Internal Changes

  • Refactored cycleDetectorInjector to use unified RetrieveBind method
  • Simplified standard_injector implementation with consolidated retrieval logic
  • Improved error handling consistency across all retrieve functions
  • Error system refactoring: Replaced old error utilities with structured error types in internal/errors package:
    • Created sentinel errors for backward compatibility (ErrAlreadyBoundSentinel, ErrElementNotRegisteredSentinel, etc.)
    • Implemented proper error wrapping and checking with errors.Is() and errors.As()
    • Added error re-exports in public remy package for backward compatibility
  • GetWithPairs enhancement: Now supports providing BindKey directly via InstancePair.Key field, allowing usage without reflection when keys are explicitly provided