Skip to content
프로젝트

소개

⚙️ Go 1.18+ 제네릭을 기반으로 한 의존성 주입 툴킷.

개발 도구

이 수치를 측정하는 방법

What you can do

  • Register by type
  • Register by name
  • Register multiple services from a package at once
  • Transient loading

측정된 스타 증가

in 24h
0
in 7 days
+2
in 15 days
+3
in 1 month
+8

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

do - Dependency Injection

tag Go Version GoDoc Build Status Go report Coverage License

⚙️ A dependency injection toolkit based on Go 1.18+ Generics.

This library implements the Dependency Injection design pattern. It may replace the fantastic uber/dig package. samber/do uses Go 1.18+ generics and therefore offers a type‑safe API.

image

See also:

  • samber/ro: Reactive Programming for Go: declarative and composable API for event-driven applications
  • samber/lo: A Lodash-style Go library based on Go 1.18+ Generics
  • samber/mo: Monads based on Go 1.18+ Generics (Option, Result, Either...)
  • samber/cc-skills-golang: AI Agent Skills for Golang


Why this name?

I love the short name for such a utility library. This name is the sum of DI and Go and no Go package uses this name.

💡 Features

  • 📒 Service registration
    • Register by type
    • Register by name
    • Register multiple services from a package at once
  • 🪃 Service invocation
    • Eager loading
    • Lazy loading
    • Transient loading
    • Tag-based invocation
    • Circular dependency detection
  • 🧙‍♂️ Service aliasing
    • Implicit (provide struct, invoke interface)
    • Explicit (provide struct, bind interface, invoke interface)
  • 🔁 Service lifecycle
    • Health check
    • Graceful unload (shutdown)
    • Dependency-aware parallel shutdown
    • Lifecycle hooks
  • 📦 Scope (a.k.a module) tree
    • Visibility control
    • Dependency grouping
  • 📤 Container
    • Dependency graph resolution and visualization
    • Default container
    • Container cloning
    • Service override
  • 🧪 Debugging & introspection
    • Explain APIs: scope tree and service dependencies
    • Web UI & HTTP middleware (std, Gin, Fiber, Echo, Chi)
  • 🌈 Lightweight, no dependencies
  • 🔅 No code generation
  • 😷 Type‑safe API

🚀 Install

# v2 (latest)
go get github.com/samber/do/v2@latest

# v1
go get github.com/samber/[email protected]

# AI Agent Skill
npx skills add https://github.com/samber/cc-skills-golang --skill golang-samber-do

This library is v2 and follows SemVer strictly.

No breaking changes will be made to exported APIs before v3.0.0.

This library has no dependencies except the Go std lib.

🔥 Migration from v1 to v2

Documentation here

🤠 Documentation

🎬 Project boilerplate

🤝 Contributing

Don't hesitate ;)

# Install some dev dependencies
make tools

# Run tests
make test
# or
make watch-test

👤 Contributors

💫 Show your support

Give a ⭐️ if this project helped you!

GitHub Sponsors

📝 License

Copyright © 2022 Samuel Berthe.

This project is MIT licensed.

관련 프로젝트 살펴보기

불러오는 중…