{"id":42170587,"url":"https://github.com/xchapter7x/ineed","last_synced_at":"2026-01-26T21:26:48.520Z","repository":{"id":57527719,"uuid":"48335304","full_name":"xchapter7x/ineed","owner":"xchapter7x","description":"easily give your structs and constructors what they need","archived":false,"fork":false,"pushed_at":"2015-12-21T14:55:44.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T03:35:43.768Z","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/xchapter7x.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}},"created_at":"2015-12-20T20:02:45.000Z","updated_at":"2015-12-21T12:33:17.000Z","dependencies_parsed_at":"2022-09-26T18:11:53.557Z","dependency_job_id":null,"html_url":"https://github.com/xchapter7x/ineed","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xchapter7x/ineed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xchapter7x%2Fineed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xchapter7x%2Fineed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xchapter7x%2Fineed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xchapter7x%2Fineed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xchapter7x","download_url":"https://codeload.github.com/xchapter7x/ineed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xchapter7x%2Fineed/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28788370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:13:08.818Z","status":"ssl_error","status_checked_at":"2026-01-26T21:13:08.448Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-26T21:26:47.955Z","updated_at":"2026-01-26T21:26:48.515Z","avatar_url":"https://github.com/xchapter7x.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"#I Need\n\n## easily give your structs and constructors what they need\n\n[![wercker status](https://app.wercker.com/status/92296b904aa18774452c79ab3c3c295d/s/master \"wercker status\")](https://app.wercker.com/project/bykey/92296b904aa18774452c79ab3c3c295d)\n[![Coverage Status](https://coveralls.io/repos/xchapter7x/ineed/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/xchapter7x/ineed?branch=master)\n\n### Written because:\n* all i need is a clean way to invert control\n* i want to keep as close to idiomatic go struct initialization as possible\n* i dont want struct element tags (thats way too much like annotations for me)\n* I dont want a over the top DI framework\n* I dont want be required to have a 100 argument 'New' constructor functions in my packages\n* I want to just be able to pass in fakes or real objects to initialize my structs with\n\n### Examples:\n\n```\n\npackage main\n\nimport (\n\t\"fmt\"\n\n\ti \"github.com/xchapter7x/ineed\"\n)\n\nfunc NewFromType(deps i.Need) *Something {\n\ts := new(Something)\n\tdeps.CastInto(s)\n\treturn s\n}\n\nfunc NewWithUnexported(deps i.Need) *Something {\n\ts := \u0026Something{\n\t\trandomPriv: deps.Get(\"randomPriv\").(string),\n\t}\n\tdeps.MapInto(s)\n\treturn s\n}\n\nfunc New(deps i.Need) *Something {\n\ts := new(Something)\n\tdeps.MapInto(s)\n\treturn s\n}\n\ntype Something struct {\n\trandomPriv string\n\tRandomPub  string\n\tCool       CoolObject\n}\n\ntype CoolObject struct {\n\tAField       string\n\tAnotherField string\n}\n\nfunc (s Something) PrintAll() {\n\tfmt.Println(s.randomPriv)\n\tfmt.Println(s.RandomPub)\n\tfmt.Println(s.Cool)\n}\n\nfunc main() {\n\tdeps := i.Want().\n\t\tToMap(\"RandomPub\", \"i am public\").\n\t\tToMap(\"randomPriv\", \"i am private\")\n\n\tcoolDep := CoolObject{\n\t\tAField:       \"inject me\",\n\t\tAnotherField: \"Don't forget me too\",\n\t}\n\tblindDeps := i.Want().\n\t\tToUse(coolDep)\n\n\tsomething := New(deps)\n\tsomething.PrintAll()\n\n\tsomethingPrivate := NewWithUnexported(deps)\n\tsomethingPrivate.PrintAll()\n\n\tsomethingWithRandomNamedFields := NewFromType(blindDeps)\n\tsomethingWithRandomNamedFields.PrintAll()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxchapter7x%2Fineed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxchapter7x%2Fineed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxchapter7x%2Fineed/lists"}