{"id":28847629,"url":"https://github.com/livebud/di","last_synced_at":"2025-08-24T09:18:04.056Z","repository":{"id":185221939,"uuid":"673193512","full_name":"livebud/di","owner":"livebud","description":"Dependency injection using Generics.","archived":false,"fork":false,"pushed_at":"2023-10-08T23:31:28.000Z","size":19,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T09:42:02.780Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/livebud.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-01T04:52:05.000Z","updated_at":"2024-03-30T17:05:54.000Z","dependencies_parsed_at":"2023-08-01T05:52:28.570Z","dependency_job_id":null,"html_url":"https://github.com/livebud/di","commit_stats":null,"previous_names":["livebud/di"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/livebud/di","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livebud%2Fdi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livebud%2Fdi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livebud%2Fdi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livebud%2Fdi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/livebud","download_url":"https://codeload.github.com/livebud/di/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livebud%2Fdi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260818656,"owners_count":23067746,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-19T19:40:59.581Z","updated_at":"2025-08-24T09:18:04.047Z","avatar_url":"https://github.com/livebud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DI\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/livebud/di.svg)](https://pkg.go.dev/github.com/livebud/di)\n\nDependency injection using Generics.\n\n## Features\n\n- Provide dependencies in a natural and type-safe way\n- Register dependencies with other dependencies (e.g. register a controller with the router)\n- Swap out dependencies during testing\n- Middleware support\n- Unmarshal dependencies into a struct\n\n## Install\n\n```\ngo get github.com/livebud/di\n```\n\n## Example\n\nIn the following example, we load the logger which loads the environment:\n\n```go\ntype Env struct {\n  DatabaseURL string\n}\n\nfunc provideEnv(in di.Injector) (*Env, error) {\n  return \u0026Env{\n    DatabaseURL: \"postgres://localhost:5432/db\",\n  }, nil\n}\n\ntype Log struct {\n  env *Env\n}\n\nfunc provideLog(in di.Injector) (*Log, error) {\n  env, err := di.Load[*Env](in)\n  if err != nil {\n    return nil, err\n  }\n  return \u0026Log{env}, nil\n}\n\nfunc main() {\n  in := di.New()\n  di.Provide(in, provideEnv)\n  di.Provide(in, provideLog)\n  log, err := di.Load[*Log](in)\n  fmt.Println(log.env.DatabaseURL)\n}\n```\n\n## Contributors\n\n- Matt Mueller ([@mattmueller](https://twitter.com/mattmueller))\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivebud%2Fdi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivebud%2Fdi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivebud%2Fdi/lists"}