{"id":19621634,"url":"https://github.com/pkg6/gdi","last_synced_at":"2025-09-16T01:31:24.908Z","repository":{"id":192571073,"uuid":"653654169","full_name":"pkg6/gdi","owner":"pkg6","description":"A simple yet powerful dependency injection container for Go.","archived":true,"fork":false,"pushed_at":"2025-05-20T06:06:40.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-20T07:23:37.184Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkg6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-14T13:16:18.000Z","updated_at":"2025-05-20T06:06:53.000Z","dependencies_parsed_at":"2023-12-15T10:48:37.917Z","dependency_job_id":null,"html_url":"https://github.com/pkg6/gdi","commit_stats":null,"previous_names":["pkg6/gdi"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pkg6/gdi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fgdi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fgdi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fgdi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fgdi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkg6","download_url":"https://codeload.github.com/pkg6/gdi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkg6%2Fgdi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275348305,"owners_count":25448628,"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","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2024-11-11T11:23:49.548Z","updated_at":"2025-09-16T01:31:24.585Z","avatar_url":"https://github.com/pkg6.png","language":"Go","readme":"A simple yet powerful dependency injection container for Go.\n\n## Installation\n\n```\ngo get -u github.com/pkg6/gdi\n```\n\n## Usage\n\nCreate a container\n\n```\ncontainer := container.New()\n```\n\n##  Set a value\n\n```\ncontainer.Set(\"foo\", \"bar\")\n```\n\n##  Get a value\n\n```\nvalue,err:= container.Get(\"foo\") // value is \"bar\"\n```\n\n## Check if a value exists\n\n```\nexists := container.Exists(\"foo\") // exists is true\n```\n\n##  Unset a value\n\n```\ncontainer.Unset(\"foo\")\n```\n\n## Register a service provider\n\n```\ntype DemoServiceProvider struct {\n}\nfunc (d DemoServiceProvider) Register(container IContainer) {\n\tcontainer.Set(\"foo\", \"bar\")\n}\nsp := \u0026DemoServiceProvider{}\ncontainer.Register(sp)\n```\n\n## Register a Object\n\n```\ntype Foo struct {\n\tcontainer IContainer\n}\n\nfunc (f *Foo) Construct(container IContainer) {\n\tf.container = container\n}\n\nfoo := \u0026Foo{}\nc.Set(\"foo\", foo)\n```\n\nThe service provider can then set values in the container\n\n## Register a HandlerFunc\n\n```\nc.Handler(func(container IContainer) {\n  container.Set(\"handler\", \"handler\")\n})\n```\n\nThe service provider can then set values in the container\n\n## Panic handling\n\nMethods like Get and Raw will panic if the identifier does not exist. You can recover from panics to handle the error in a graceful way:\n\n```\ndefer func() {\n  if err := recover(); err != nil {\n    // handle error\n  }\n}()\nvalue = container.Get(\"not-exist\")  // Will panic\n```\n\n## Contributors\n\n[@pkg6](https://github.com/pkg6/gdi)\n\n## License\n\nContainer is licensed under the MIT license. See the [LICENSE](https://github.com/pkg6/gdi/blob/main/LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkg6%2Fgdi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkg6%2Fgdi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkg6%2Fgdi/lists"}