golang-samber-do

Solid

Implements dependency injection in Golang using samber/do. Apply this skill when working with dependency injection, setting up service containers, managing service lifecycles, or when you see code using github.com/samber/do/v2. Also use when refactoring manual dependency injection, implementing health checks, graceful shutdown, or organizing services into scopes/modules.

AI & Automation 0 stars 0 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 78/100

Stars 20%
0
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

**Persona:** You are a Go architect setting up dependency injection. You keep the container at the composition root, depend on interfaces not concrete types, and treat provider errors as first-class failures. # Using samber/do for Dependency Injection in Go Type-safe dependency injection toolkit for Go based on Go 1.18+ generics. **Official Resources:** - [pkg.go.dev/github.com/samber/do/v2](https://pkg.go.dev/github.com/samber/do/v2) - [do.samber.dev](https://do.samber.dev) - [github.com/samber/do/v2](https://github.com/samber/do) This skill is not exhaustive. Please refer to library documentation and code examples for more information. Context7 can help as a discoverability platform. DO NOT USE v1 OF THIS LIBRARY. INSTALL v2 INSTEAD: ```bash go get -u github.com/samber/do/v2 ``` ## Core Concepts ### The Injector (Container) ```go import "github.com/samber/do/v2" injector := do.New() ``` ### Service Types - **Lazy** (default): Created when first requested - **Eager**: Created immediately when the container starts - **Transient**: New instance created on every request - **Value**: Pre-created value, no instantiation ### Provider Functions Services MUST be registered via provider functions: ```go type Provider[T any] func(i Injector) (T, error) ``` ## Basic Usage ### 1. Define and Register Services Follow "Accept Interfaces, Return Structs": ```go // Register a service (lazy by default) do.Provide(injector, func(i do.Injector) (Database, error) { return...

Details

Author
guynhsichngeodiec
Repository
guynhsichngeodiec/cc-skills-golang
Created
3 months ago
Last Updated
yesterday
Language
Go
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

golang-dependency-injection

Comprehensive guide for dependency injection (DI) in Golang. Covers why DI matters (testability, loose coupling, separation of concerns, lifecycle management), manual constructor injection, and DI library comparison (google/wire, uber-go/dig, uber-go/fx, samber/do). Use this skill when designing service architecture, setting up dependency injection, refactoring tightly coupled code, managing singletons or service factories, or when the user asks about inversion of control, service containers, or wiring dependencies in Go.

0 Updated yesterday
guynhsichngeodiec
AI & Automation Solid

golang-samber-mo

Monadic types for Golang using samber/mo — Option, Result, Either, Future, IO, Task, and State types for type-safe nullable values, error handling, and functional composition with pipeline sub-packages. Apply when using or adopting samber/mo, when the codebase imports `github.com/samber/mo`, or when considering functional programming patterns as a safety design for Golang.

0 Updated yesterday
guynhsichngeodiec
Data & Documents Solid

golang-samber-ro

Reactive streams and event-driven programming in Golang using samber/ro — ReactiveX implementation with 150+ type-safe operators, cold/hot observables, 5 subject types (Publish, Behavior, Replay, Async, Unicast), declarative pipelines via Pipe, 40+ plugins (HTTP, cron, fsnotify, JSON, logging), automatic backpressure, error propagation, and Go context integration. Apply when using or adopting samber/ro, when the codebase imports github.com/samber/ro, or when building asynchronous event-driven pipelines, real-time data processing, streams, or reactive architectures in Go. Not for finite slice transforms (-> See golang-samber-lo skill).

0 Updated yesterday
guynhsichngeodiec