golang-samber-do

Configure samber/do v2 containers for Go dependency injection and lifecycle management.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/dashkan/pivox --skill golang-samber-do-dashkan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-do
Source: https://github.com/dashkan/pivox/tree/main/.agents/skills/golang-samber-do
Command: npx skills add https://github.com/dashkan/pivox --skill golang-samber-do-dashkan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you replace manual constructor wiring with type-safe dependency injection in Go, so services are composed correctly and consistently with lifecycle management and reliable startup/shutdown behavior.

Core Features & Use Cases

  • Type-safe service registration (v2): Build containers using providers that return concrete implementations while invoking as interfaces.
  • Lifecycle control: Choose lazy (default), eager, and transient service creation to match runtime needs and avoid unnecessary work.
  • Production-grade container operations: Organize registrations with packages, manage scopes, add health checks, and support graceful shutdown.

Quick Start

Use the golang-samber-do skill to set up a samber/do v2 container that registers your config and database provider at composition root, then builds and shuts down services properly.

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 Go using samber/do?

To set up dependency injection in Go using samber/do, you register services at the composition root using provider functions that return (T, error), then invoke them via Invoke or MustInvoke, ensuring type-safe service composition and deterministic wiring.

What is the difference between lazy, eager, and transient service lifecycles in Go DI containers?

In Go DI containers, lazy services initialize on first invocation, eager services initialize immediately at registration, and transient services create a new instance per invocation. Choosing the right lifecycle prevents unnecessary work and manages runtime resource allocation.

How do I manage graceful shutdown and health checks in a Go service container?

You manage graceful shutdown and health checks in a Go service container by utilizing samber/do's built-in lifecycle management, which allows services to be properly started and stopped, and by registering health check providers to monitor service availability during runtime.

Can I use scoped initialization for multi-module Go applications?

Yes, you can use scoped initialization for multi-module Go applications. Samber/do supports scopes and packages, allowing you to organize service registrations hierarchically and control dependency resolution across different application boundaries.

How do I invoke a service as an interface when the provider returns a concrete type in Go?

To invoke a service as an interface when the provider returns a concrete type, you use the InvokeAs function in samber/do. This allows type-safe registration of concrete implementations while resolving them through their expected interfaces at the call site.

When should I replace manual constructor wiring with a Go dependency injection container?

You should replace manual constructor wiring with a Go dependency injection container when composing multi-module applications that require consistent lifecycle management, deterministic composition roots, health checks, and graceful shutdown behavior to ensure reliable startup and shutdown.