Implement type-safe dependency injection in Go with submodule.go by registering providers via Make, resolving lazily, managing scopes and groups, applying middleware, testing with mocks, and auditing code to avoid anti-patterns.

Does the demonstrated diagram look familiar to you? A lot of applications will look just like so.
Without any IoC or Dependency Injection framework / libraries, those applications will suffer from those issues
main method, and will be scattered to all servicesTak Register user handler as an example, to setup the test for it
User serviceDb connectionConfigSubmodule was born to balance the Ioc wiring, so you don't have to pull your hairs just to test your app
Submodule is built around the concept of function composition. A component will be hidden/lazy initialized behind a function. And if another module requires that component, submodule will associate those factory functions. The initialization will only happen when one of those components got used
So, Submodule will just replicate exactly what described as dependencies in the diagram, and only initialized when one of those components got called
Then, with the knowledge of dependencies like so, Submodule will initialize just what it is needed to support testing
package main
import (
"fmt"
"net/http"
"github.com/submodule-org/submodule.go/v2"
)
type Config struct {
Host string
Port int
LogLevel string
}
func LoadConfig() Config {
// load config from ENV etc
return Config{
Host: "", // value from env or default value
Port: 0, // value from env or default value
LogLevel: "debug", // value from env or default value
}
}
// ConfigMod will be the singleton container for config value
var ConfigMod = submodule.Make[Config](LoadConfig)
type logger struct {
LogLevel string
}
type Logger interface {
Log(msg ...string)
}
func (l *logger) Log(msgs ...string) {
// log implementation with log level
}
var LoggerMod = submodule.Make[Logger](func(config Config) Logger {
return &logger{
LogLevel: config.LogLevel,
}
}, ConfigMod)
type server struct {
Config Config
Logger Logger
}
func (s *server) Start() {
go func() {
http.ListenAndServe(fmt.Sprintf("%s:%d", s.Config.Host, s.Config.Port), nil)
}()
}
var ServerMod = submodule.Resolve(&server{}, ConfigMod, LoggerMod)
func main() {
server := ServerMod.Resolve()
server.Start()
}
This repo includes a Claude Code plugin that teaches Claude how to use submodule.go correctly — DI registration, testing with isolated scopes, mocking, anti-patterns, and more.
/plugin marketplace add submodule-org/submodule.go
/plugin install submodule-go@submodule-go-marketplace
Use the /submodule-go slash command, or the skill triggers automatically when working with submodule.go imports.
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
npx claudepluginhub submodule-org/submodule.go --plugin submodule-goComprehensive skill pack with 66 specialized skills for full-stack developers: 12 language experts (Python, TypeScript, Go, Rust, C++, Swift, Kotlin, C#, PHP, Java, SQL, JavaScript), 10 backend frameworks, 6 frontend/mobile, plus infrastructure, DevOps, security, and testing. Features progressive disclosure architecture for 50% faster loading.
Unity Development Toolkit - Expert agents for scripting/refactoring/optimization, script templates, and Agent Skills for Unity C# development
Comprehensive .NET development skills for modern C#, ASP.NET, MAUI, Blazor, Aspire, EF Core, Native AOT, testing, security, performance optimization, CI/CD, and cloud-native applications
Modern R development skills for Claude Code - tidyverse patterns, rlang metaprogramming, Bayesian inference, performance optimization, and more
Tools to maintain and improve CLAUDE.md files - audit quality, capture session learnings, and keep project memory current.
Complete creative writing suite with 10 specialized agents covering the full writing process: research gathering, character development, story architecture, world-building, dialogue coaching, editing/review, outlining, content strategy, believability auditing, and prose style/voice analysis. Includes genre-specific guides, templates, and quality checklists.