{"id":36526985,"url":"https://github.com/kitstack/depkit","last_synced_at":"2026-04-20T08:12:47.426Z","repository":{"id":65115754,"uuid":"581924475","full_name":"kitstack/depkit","owner":"kitstack","description":"This package provides a simple way to manage dependencies in a Go application. It allows you to register and retrieve dependencies using Go interfaces.","archived":false,"fork":false,"pushed_at":"2023-04-28T02:47:21.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-15T07:27:20.757Z","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/kitstack.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}},"created_at":"2022-12-24T22:15:14.000Z","updated_at":"2023-04-28T02:51:05.000Z","dependencies_parsed_at":"2024-02-12T02:02:38.460Z","dependency_job_id":null,"html_url":"https://github.com/kitstack/depkit","commit_stats":null,"previous_names":["lab210-dev/depkit","lab210-dev/service","lab210-dev/servicekit","jackgianesini/depkit","kitstack/depkit"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kitstack/depkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitstack%2Fdepkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitstack%2Fdepkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitstack%2Fdepkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitstack%2Fdepkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitstack","download_url":"https://codeload.github.com/kitstack/depkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitstack%2Fdepkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32038608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"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":"2026-01-12T02:56:44.731Z","updated_at":"2026-04-20T08:12:47.418Z","avatar_url":"https://github.com/kitstack.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go](https://github.com/kitstack/depkit/actions/workflows/coverage.yml/badge.svg)](https://github.com/kitstack/depkit/actions/workflows/coverage.yml)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/kitstack/depkit)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kitstack/depkit)](https://goreportcard.com/report/github.com/kitstack/depkit)\n[![codecov](https://codecov.io/gh/kitstack/depkit/branch/main/graph/badge.svg?token=3JRL5ZLSIH)](https://codecov.io/gh/kitstack/depkit)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/kitstack/depkit/blob/main/LICENSE)\n[![Github tag](https://badgen.net/github/release/kitstack/depkit)](https://github.com/kitstack/depkit/releases)\n\n# Overview\nThis package provides a simple way to manage dependencies in a Go application. It allows you to register and retrieve dependencies using Go interfaces.\n\nIt simplifies the process of writing unit tests by providing a simple and easy-to-use interface for managing dependencies between different components of your application. It allows you to register dependencies and callbacks, and retrieve them whenever needed, making it easy to test your code in isolation. This results in more maintainable and reliable tests, as well as a faster development process.\n\n## Installation\nTo install this package, use the `go get` command:\n\n```bash\ngo get github.com/kitstack/depkit\n```\n\n## 📚 Usage\nTo use this package, you must first register your dependency using the Register function :\n\n```go\npackage example\n\nimport \"github.com/kitstack/depkit\"\n\ntype MyService interface {\n\tDoSomething()\n}\n\ntype myServiceImpl struct{}\n\nfunc (s *myServiceImpl) DoSomething() {\n\t// Do something here...\n}\n\nfunc init() {\n\tdepkit.Register[MyService](new(myServiceImpl))\n}\n```\n\nYou can now retrieve your service using the `Get` function :\n\n```go\npackage example\n\nimport \"github.com/kitstack/depkit\"\n\ntype MyService interface {\n\tDoSomething()\n}\n\nfunc main() {\n\tdepkit.Get[MyService]().DoSomething()\n}\n```\n\nYou can also use the GetAfterRegister function to execute a callback once the service has been registered :\n\n```go \npackage example\n\nimport \"github.com/kitstack/depkit\"\n\ntype MyService interface {\n\tDoSomething()\n}\n\nfunc main() {\n    depkit.GetAfterRegister[MyService](func(s MyService) {\n        s.DoSomething()\n    })\n}\n```\n\nTo reset all registered dependencies, use the Reset function :\n```go\npackage example\n\nimport \"github.com/kitstack/depkit\"\n\nfunc main() {\n\tdepkit.Reset()\n}\n```\n\n### Notes\n- Services must be registered using interfaces or func, not concrete types.\n- If you try to retrieve a dependency that has not been registered, an error will panic.\n\n## ⚡️ Benchmark\n\n```text\ngoos: darwin\ngoarch: arm64\npkg: github.com/kitstack/depkit\nBenchmarkGet\nBenchmarkGet-10                 \t 6982549\t       170.8 ns/op\nBenchmarkRegister\nBenchmarkRegister-10            \t 7061115\t       164.9 ns/op\nBenchmarkGetAfterRegister\nBenchmarkGetAfterRegister-10    \t 5401953\t       223.9 ns/op\n```\n\n## 🤝 Contributions\nContributors to the package are encouraged to help improve the code.\n\nIf you have any questions or comments, don't hesitate to contact me.\n\nI hope this package is helpful to you !","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitstack%2Fdepkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitstack%2Fdepkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitstack%2Fdepkit/lists"}