{"id":16614424,"url":"https://github.com/belak/go-resolve","last_synced_at":"2026-04-18T21:02:01.419Z","repository":{"id":57481690,"uuid":"58597544","full_name":"belak/go-resolve","owner":"belak","description":"A small library to handle ordering for constructor functions","archived":false,"fork":false,"pushed_at":"2018-12-11T19:14:24.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T18:05:14.674Z","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/belak.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":"2016-05-12T01:44:18.000Z","updated_at":"2018-12-11T19:14:26.000Z","dependencies_parsed_at":"2022-09-02T06:03:21.783Z","dependency_job_id":null,"html_url":"https://github.com/belak/go-resolve","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/belak/go-resolve","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgo-resolve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgo-resolve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgo-resolve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgo-resolve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/belak","download_url":"https://codeload.github.com/belak/go-resolve/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belak%2Fgo-resolve/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31984557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"ssl_error","status_checked_at":"2026-04-18T20:23:29.375Z","response_time":103,"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":"2024-10-12T02:06:10.761Z","updated_at":"2026-04-18T21:02:01.367Z","avatar_url":"https://github.com/belak.png","language":"Go","readme":"# go-resolve\n\n[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/belak/go-resolve)\n[![Travis](https://img.shields.io/travis/belak/go-resolve.svg)](https://travis-ci.org/belak/go-resolve)\n[![Coveralls](https://img.shields.io/coveralls/belak/go-resolve.svg)](https://coveralls.io/github/belak/go-resolve)\n\n## Why write this? Isn't dependency injection bad?\n\nAfter messing with plugin systems for a while, one of the hardest\nproblems to solve is plugin dependencies and loading things in a\ncertain order. For generic systems, it can be hard to handle this\nproperly in a safe manner.\n\n`go-resolve` is intended to be a small wrapper around dependency\ninjection to determine the proper load order of factory-like plugins\nand load them.\n\nDependency injection is generally frowned upon in go, but I view this\nas an acceptable trade-off to make writing plugin systems\nsimpler. Additionally, running dependency injection once on startup,\nrather than every time an event happens, makes this simpler to manage\nand reduces the problem surface to the point where it should be\ntestable.\n\n## But empty interfaces are bad!\n\nYes, this is true. Using empty interfaces in too many places is\ngenerally a code smell. However, in order to accept a function with\nany signature, this is a requirement.\n\nWe work around this by checking that the function will be valid for\ninjection at the time it's added.\n\n## How does it work?\n\nThe actual concept behind ordering dependencies is fairly\nsimple. Essentially, a dependency graph needs to be created, then you\ncan just run a topological sort on the graph. The order of the nodes\nfrom that sort is the order items needs to be loaded in.\n\nWhen we add a function to a resolver, we generate a graph node which\ncontains a list of all the types needed to run that function as well\nas which types are returned. Any error types are ignored until the\nfunction itself is run.\n\nAfter all nodes are added, simply call Resolve. This will determine\nthe load order, load all plugins, and add any non-error return values\nto an Injector for use after plugins are loaded. If any function\nreturns a non-nil error value, that will be returned as soon as it\nhappens.\n\n## Other stuff\n\nBe sure to check out [go-plugin](https://github.com/belak/go-plugin),\nwhich was my main reason for writing this.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelak%2Fgo-resolve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbelak%2Fgo-resolve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelak%2Fgo-resolve/lists"}