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

Changelog

2025

2025-12-24 v1.11.0

Breaking Changes

  • Removed reflection options from Config: The Config struct no longer includes GenerifyInterfaces and UseReflectionType fields. These options have been completely removed from the library as part of a simplification effort.
  • Removed ReflectionOptions type: The ReflectionOptions type has been removed. All reflection-based functionality has been eliminated in favor of compile-time type safety.
  • GetWithPairs API change: GetWithPairs now uses the new BindEntry interface instead of InstancePairAny. The parameter order has also changed: keyTag is now the second parameter (before elements).
    • Before: GetWithPairs[T](retriever, elements []InstancePairAny, optTag ...string)
    • After: GetWithPairs[T](retriever, elements []BindEntry, optTag ...string)
  • GetWith parameter order change: The keyTag parameter is now required and comes before the binder function parameter in internal methods. The public API maintains backward compatibility with optional tags.
  • Removed deprecated functions: The remy_deprecated.go file and all deprecated function wrappers have been removed. If you were using deprecated functions, you must migrate to the new API.

Added

  • BindEntry interface: New interface for passing temporary dependencies to GetWithPairs. Provides a cleaner, type-safe API compared to the previous InstancePairAny struct.
    • NewBindEntry[T](value T) BindEntry: Creates a BindEntry with the given value and no tag
    • NewBindEntryTagged[T](value T, tag string) BindEntry: Creates a BindEntry with the given value and tag
  • Improved type key generation: Enhanced KeyElem with better ID generation using unsafe pointers for improved performance.

Changed / Improved

  • Internal method signatures: All internal injector methods now use keyTag string instead of optTag ...string for better clarity and consistency. The public API maintains backward compatibility.
  • Storage key validation: Storage now properly validates and checks for empty keys, preventing potential issues with uninitialized bind keys.
  • Performance improvements: Storage access has been optimized using unsafe pointers for better performance.

Refactor

  • Removed reflection dependencies: All reflection-based type key generation and type identification has been removed from the core library, improving compile-time safety and performance.
  • Simplified injector configuration: The Config struct is now simpler and more focused, removing complex reflection options that were rarely needed.
  • Updated examples: All examples have been updated to use the new BindEntry API and no longer reference reflection options.

Tests

  • Updated all injector tests to include keyTag in internal method calls
  • Added tests for the new BindEntry API
  • Tests adapted to work without reflection options

2025-12-10 v1.10.2

Fixed

  • Pointer type duck typing assertion: Fixed an issue where pointer types (e.g., *GoLanguage) registered as binds could not be correctly asserted to interfaces (e.g., Language) when using duck typing. Previously, checkSavedAsBind was only using PointerValue(), which for pointer types like *GoLanguage would return **GoLanguage (a double pointer) that cannot be asserted to the Language interface. The function now first checks DefaultValue() for type assertion, and if that fails, it falls back to PointerValue() which correctly returns a pointer that can be asserted to the interface. This ensures that pointer types can be properly retrieved via duck typing when searching for interface implementations.

2025-12-10 v1.10.1

Fixed

  • Sub-injector GetAll delegation: Fixed an issue where sub-injectors (created via GetWith or GetWithPairs) could not use duck typing to find interfaces from parent injectors when the sub-injector didn’t have CacheOptReturnAll enabled. The GetAll method now correctly ignores ErrConfigNotAllowReturnAll for sub-injectors and delegates to the parent injector, allowing duck typing to work correctly even when the sub-injector’s storage doesn’t allow GetAll operations.

2025-11-21 v1.10.0

Added

  • Module system for composing registrations:
    • NewModule(registers ...ModuleRegister) Module
    • RegisterModule(inj Injector, modules ...Module) error
    • RegisterModuleFunc(inj Injector, fns ...func(Injector)) error
  • Module helpers (functional options) to adapt existing Register API for modules:
    • WithBind, WithInstance, WithFactory, WithSingleton, WithLazySingleton
    • WithConstructor, WithConstructor1, WithConstructor2, WithConstructor3, WithConstructor4 (error-returning only)
  • Context-aware retrieval: GetWithContext[T](inj Injector, ctx context.Context) (T, error)

Changed / Improved

  • Documentation reorganized and expanded:
    • New Modules section with usage examples
    • Retrieve Type docs expanded, including duck typing guidance and GetAll family for multiple matches

Performance

  • Avoid unnecessary duck-typing checks for non-interface requests, improving Get performance when DuckTypeElements is enabled but a concrete type is requested.
  • Minor optimizations to error creation paths.

Fixed

  • Wrap GetAll error on parent injector to provide clearer error propagation when resolving across parent/child injectors.
  • Ensure generifyInterface option only applies to interfaces.
  • Various documentation fixes and consistency updates.

Refactor

  • Moved storage implementation into a dedicated internal package for clearer boundaries.
  • Internal cleanups and lint fixes.

Tests

  • Added tests for module registration, constructor helpers within modules, recovery/partial application on module errors, and composing multiple modules.
  • Added test to ensure parallel calls for Get methods behave as expected.

2025-11-10 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

2024

2024-05-26 v1.8.2

  • Update GetAll method (and also duck type get) to retrieve objects stored as Bind[T]
    • This update add a little more overhead to check if the bind implements the type we’re searching for
    • Created a new function on Binds to try to prevent stack-overflow and cycle dependency get
    • If everything matches, this new way of returning duck-type elements will call the Generate method on bind
      • It must be very careful about cycle dependencies now more than ever
  • Add tests to cover the new duckType mode with Bind[T]
  • Add new functions to register constructors with the injector.
    • RegisterConstructor - RegisterConstructorErr
    • RegisterConstructorArgs1 - RegisterConstructorArgs1Err
    • RegisterConstructorArgs2 - RegisterConstructorArgs2Err
  • Add tests to cover new constructor registration.

2023

2023-06-17 v1.8.0

  • Replace internal type detection
    • Stop using fmt.Sprintf which uses reflection by default
    • Optimize existent function TypeNameByReflection
    • Add 0-width generic type that will be used as key for injections
  • Change BindKey type to any
  • Upgrade minimal go-version to 1.20
    • This was made to be able to use any as comparable
  • Remove GenerifyInterfaces=true from default injector Config

2023-04-07 v1.7.0

  • Add a new config option to guess element type
    • It only works for instance binds
    • Is strongly recommended to not use
    • Add test cases for new element guessing system
  • Create an example that uses the new element guessing option
  • Add new errors on utils package
  • Remove unused Default[T any]() T function from utils
  • Refactor cacheConfig internally to use bitwise operators on numeric element
    • This will allow to pass less parameters to constructors

2022

2022-10-06 v1.6.0

  • Change remy.Binder to return an error alongside with the value
    • Update all tests to match the new Binder function
  • Add new option in InstancePair to bind interfaces
  • Change the internal use of ReflectionOptions to use bitwise operators
    • In this way it’ll be possible to add more internal options in the future

2022-09-26 v1.5.0

  • Move package utils from internal to pkg
  • Swap all string length comparison with empty string check
  • Add BindKey & ReflectOptions to public API
  • Add tests for func type
  • Update README/SPEC markdown
  • Add an error to Get method
  • Create an example to know how to get logs from Injector
    • This example needs to use unexported packages yet, so it will need update after the release
  • Update bind.Instance to not use remy.Binder functions
  • Change RegisterSingleton function signature

2022-08-01 v1.4.0

  • Create CycleDetectorInjector to be used in tests
    • Create a new error type
    • Create a new type in internal utilities
  • Change use of unexported type to an exported in public pkg
    • remy public functions now use Bind[T] instead of types.Bind[T]
  • Add WrapRetriever to DependencyRetriever interface
  • Add panic recover to Do functions
  • Remove sync.RWMutex from globalInjector
  • Swap type Injector by DependencyRetriever in Get methods
  • Boost performance by using pointer receiver in Injector/Storage methods

2022-07-28 v1.3.0

  • Improve test coverage
  • Rename some internal attributes in storage
    • Test SetGlobalInjector
    • Test most generics utilities
  • Return error on internal register function
  • Add godoc lines to internal.types
  • Fix hidden error on GetGen function
  • Fix error with bind register
    • Prevent overriding a same type with different type of bindings
  • Cleanup DependencyRetriever methods
    • Removed unnecessary duplicate methods
  • Internal improvements
    • Change BindKey type to prevent misplace errors
    • Remove duplicate use of storage

2022-07-24 v1.2.1

  • Fix an error with ReflectionOptions not being applied to StdInjector
  • Rename some internal attributes in storage

2022-07-21 v1.2.0

  • Replace default type resolution - Now it will not use the reflect package by default.
  • Add UseReflectionType option in Config struct
  • Improve tests coverage
    • Add test to check type resolution for elements with same type-name and package-name from another module
  • Fix GetElemKey method not being able to get the type of the interface
  • Fix an error where interface and pointer of the same type were being registered as the same type
  • Create additional "Do" methods: DoGet, DoGetGen, DoGetGenFunc
  • Refactor the Storage/Injector retrieval to return an error instead of a bool

2022-05-30 v1.1.0

  • Create README with more detailed instructions
  • Fix some typos
  • Add method SetGlobalInjector
  • Allow to define a ParentInjector in Injector constructor
  • Add more documentation in public types/methods
  • Create methods GetGen and GetGenFunc to pass values dynamically

2022-05-24 v1.0.0

  • Core release
  • Register and Retrieve using generics
  • Example in repository