golang-samber-do

Set up type-safe dependency injection in Go with samber/do.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-samber-do-jylhis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-do
Source: https://github.com/Jylhis/claude-marketplace/tree/main/plugins/golang-dev/skills/golang-samber-do
Command: npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-samber-do-jylhis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Managing dependencies manually in Go leads to tangled code, hard-to-test services, and fragile initialization order. Developers need a lightweight, type-safe way to register and resolve services without sacrificing idiomatic Go practices.

Core Features & Use Cases

  • Type-safe registration with do.Provide, do.ProvideTransient, and do.ProvideNamed for various lifecycles.
  • Implicit aliasing using do.InvokeAs to retrieve concrete implementations as interfaces.
  • Modular organization via do.Package for grouping infrastructure, domain, and transport services.
  • Scope management to isolate per-request services while sharing global configuration.
  • Testing utilities such as container cloning and overrides for mock injection.

Quick Start

Ask the skill to set up a basic samber/do container for a new Go project.

Frequently Asked Questions about golang-samber-do

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

FAQPage Schema
How do I set up type-safe dependency injection in Go without manual initialization?

You can set up dependency injection in Go using samber/do by applying Provide, ProvideTransient, and ProvideNamed at the composition root to register services with managed lifecycles and clean constructor injection.

What is the best way to organize infrastructure and domain services in a Go DI container?

Organizing Go DI container services uses do.Package to group infrastructure, domain, and transport registrations modularly, keeping the composition root clean and separating global configuration from isolated per-request scopes.

Does samber/do support retrieving a concrete implementation as an interface in Go?

Yes, samber/do supports implicit aliasing in Go using do.InvokeAs, allowing you to retrieve concrete implementations as interfaces during dependency resolution without manually registering duplicate aliases.

Can I isolate per-request services while sharing global configuration in a Go dependency injection container?

Yes, samber/do scope management isolates per-request services while sharing global configuration across the Go dependency injection container, maintaining clean boundaries for transient and scoped lifecycles.

How do I inject mocks when testing Go services that use samber/do dependency injection?

Testing Go services with samber/do dependency injection uses container cloning and overrides to inject mocks, replacing real service registrations to isolate units under test without altering production composition roots.

Do I need the samber/do v2 library installed to use this Go dependency injection skill?

Yes, you need the Go toolchain and the samber/do v2 library installed to use this dependency injection skill, as it relies on v2 features for type-safe registration, scope management, and lifecycle control.