submodule-go

Register factories and resolve dependencies lazily within scopes in Go applications.

5|2|Updated Feb 22, 2024
One-click install
npx skills add https://github.com/submodule-org/submodule.go --skill submodule-go
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: submodule-go
Source: https://github.com/submodule-org/submodule.go/tree/main/skills/submodule-go
Command: npx skills add https://github.com/submodule-org/submodule.go --skill submodule-go

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go applications often suffer from tangled wiring and hard-to-test dependencies. submodule-go provides a type-safe DI framework that registers factories and resolves dependencies lazily within scopes, improving testability and maintainability.

Core Features & Use Cases

  • Type-safe registration with Make, Resolve, Value, Group, and CreateScope to model service graphs.
  • Lazy initialization and per-scope singletons to ensure deterministic behavior and easy testing.
  • Testability via isolated scopes, mock overrides, and structural wiring (submodule.In, submodule.Self) with minimal boilerplate.
  • Supports dependency overrides and substitution to mock services in tests without changing production code.

Quick Start

Create a scope, register dependencies with Make, and Resolve a type to obtain a ready-to-use instance.

Frequently Asked Questions about submodule-go

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement type-safe dependency injection in Go without runtime errors?

Type-safe dependency injection in Go is achieved by registering factories and resolving dependencies lazily within isolated scopes. This approach ensures predictable lifecycles, deterministic behavior, and compile-time safety for struct field injection.

How do I mock dependencies in Go tests without changing production wiring code?

Mocking dependencies in Go tests is handled through dependency overrides and substitution within isolated scopes. You can inject mock services directly during resolution, ensuring testability without altering the production codebase's structural wiring.

What is the best way to manage service lifecycles and isolated scopes in Go applications?

Managing service lifecycles in Go applications is done using per-scope singletons and lazy initialization. By creating isolated scopes, you ensure deterministic behavior and prevent shared state leakage across distinct request boundaries.

Can I use lazy wiring for dependency resolution to improve Go application startup time?

Lazy wiring for dependency resolution in Go applications defers instantiation until a type is explicitly resolved. This minimizes unnecessary initialization overhead and ensures resources are only allocated when the specific dependency is required.

Does this dependency injection approach support explicit error propagation during struct field injection?

Explicit error propagation during struct field injection is fully supported during the dependency resolution process. Errors from factory functions are safely propagated back to the caller, ensuring predictable failure modes when resolving complex service graphs.