{"id":26685434,"url":"https://github.com/goapt/container","last_synced_at":"2025-03-26T10:16:04.056Z","repository":{"id":107345626,"uuid":"234214691","full_name":"goapt/container","owner":"goapt","description":"A simple dependency injection for golang","archived":false,"fork":false,"pushed_at":"2020-01-16T02:51:55.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-19T14:53:21.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goapt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-01-16T02:11:28.000Z","updated_at":"2020-01-16T02:51:57.000Z","dependencies_parsed_at":"2023-05-17T03:15:18.399Z","dependency_job_id":null,"html_url":"https://github.com/goapt/container","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fcontainer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fcontainer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fcontainer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fcontainer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goapt","download_url":"https://codeload.github.com/goapt/container/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245632400,"owners_count":20647194,"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-03-26T10:16:03.311Z","updated_at":"2025-03-26T10:16:04.042Z","avatar_url":"https://github.com/goapt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang容器注入API设计\n\n\u003ca href=\"https://github.com/goapt/container/actions\"\u003e\u003cimg src=\"https://github.com/goapt/container/workflows/container/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n[![codecov](https://codecov.io/gh/goapt/container/branch/master/graph/badge.svg)](https://codecov.io/gh/goapt/container)\n\n## API 设计\n\n### 注册容器\n```golang\ndi := container.New()\n// 绑定合约\ndi.Register(func() contract.User {\n\t return \u0026repostiory.User{}\n})\n\n// 绑定实例而非接口,并且同时依赖参数的注入，而注入的参数必须已经被注册\ndi.Register(func(user contract.User) *service.User {\n    return \u0026service.User{\n        User:user\n    }\n})\n```\n\n### 注入容器\n```golang\n//注入变量\nvar user *UserService\ndi.Make(\u0026user)\n\n\n//注入函数参数\nvar user *UserService\ndi.Make(function(user *UserService){\n    //somthing\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoapt%2Fcontainer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoapt%2Fcontainer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoapt%2Fcontainer/lists"}