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

Type Register

Remy DI supports four different bind types for registering dependencies. Each type has different instantiation behavior and lifecycle characteristics.

Bind Types

  • LazySingleton - Creates a single instance when first requested. Useful for expensive objects that may not always be needed.
  • Singleton - Creates a single instance immediately during registration. Thread-safe singleton pattern.
  • Factory - Creates a new instance every time the service is requested. Safe for concurrent use.
  • Instance - Registers an existing value directly. Best for immutable values or configuration.

Advanced Registration

  • RegisterConstructor - Convenient way to register constructor functions without manually writing the Binder function. Automatically handles dependency injection for constructor arguments.