golang-samber-do

Implement dependency injection in Golang using samber/do for service registration and scopes.

Updated May 4, 2026
One-click install
npx skills add https://github.com/VIethoangnguyenle/nexus-enterprise --skill golang-samber-do-viethoangnguyenle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-do
Source: https://github.com/VIethoangnguyenle/nexus-enterprise/tree/main/.agent/skills/golang-samber-do
Command: npx skills add https://github.com/VIethoangnguyenle/nexus-enterprise --skill golang-samber-do-viethoangnguyenle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Dependency management and wiring in Go applications can be complex and error-prone. This Skill streamlines setting up and managing dependency injection, reducing boilerplate and improving testability.

Core Features & Use Cases

  • Type-safe service registration: Easily register services with different lifecycles such as lazy, eager, or transient.
  • Structured dependency wiring: Define and inject dependencies through provider functions, scopes, and package organization.
  • Use Case: Organize a large web service with isolated modules, global services, and request-scoped dependencies, enabling clean and maintainable code.

Quick Start

Set up dependency injection by creating a container with do.New(), register services with do.Provide, and retrieve them using do.MustInvoke.

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 dependency injection in Golang using samber/do?

To set up dependency injection in Golang using samber/do, create a container with do.New(), register services via do.Provide, and retrieve them using do.MustInvoke to organize service wiring.

How do I manage different service lifecycles in a Go application?

You can manage different service lifecycles in a Go application by registering services as lazy, eager, or transient, allowing structured dependency wiring through dedicated provider functions.

What's the best way to organize dependencies for scalable Go applications?

The best way to organize dependencies for scalable Go applications is by grouping them into isolated packages, using scopes to manage request-scoped dependencies, and applying implicit aliasing via InvokeAs.

Can I use dependency injection to isolate modules for testing in Go?

Yes, you can use dependency injection to isolate modules for testing in Go, as it streamlines setting up and managing service registration, reducing boilerplate and improving testability.

Does this dependency injection approach support global and request-scoped services?

This dependency injection approach supports both global and request-scoped services, enabling you to organize a large web service with isolated modules and clean, maintainable code.