{"id":16122040,"url":"https://github.com/foxcapades/go-wildcard-env","last_synced_at":"2025-04-06T11:41:04.436Z","repository":{"id":236442333,"uuid":"692894671","full_name":"Foxcapades/go-wildcard-env","owner":"Foxcapades","description":"Variable/Wildcard environment parsing","archived":false,"fork":false,"pushed_at":"2023-09-17T23:49:43.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-12T17:19:19.447Z","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/Foxcapades.png","metadata":{"files":{"readme":"readme.adoc","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":"2023-09-17T22:40:34.000Z","updated_at":"2023-09-17T23:49:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"97145db9-e67d-4d4c-8f8c-3d37249374ee","html_url":"https://github.com/Foxcapades/go-wildcard-env","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"cb94cfa5615ec160538eb288abdf10a71724c6cd"},"previous_names":["foxcapades/go-wildcard-env"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Fgo-wildcard-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Fgo-wildcard-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Fgo-wildcard-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Fgo-wildcard-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Foxcapades","download_url":"https://codeload.github.com/Foxcapades/go-wildcard-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478234,"owners_count":20945262,"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":"2024-10-09T21:09:09.488Z","updated_at":"2025-04-06T11:41:04.397Z","avatar_url":"https://github.com/Foxcapades.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Wildcard Env Parsing\n\nLibrary for parsing groups of environment variables with wildcard matching on\nnames.\n\nSay, for example, that you have want to match groups of environment variables\nthat have a pattern to their names:\n[source, bash]\n----\nDB_\u003cWILDCARD\u003e_ADDRESS=\nDB_\u003cWILDCARD\u003e_PORT=\n----\nFor this example, say that we want to enable an arbitrary number of database\nconnections based on the groups of variables present in the process environment.\nIn this case, manually parsing or hard-coding variable names would not be an\noption.\n\nThis library allows you to match and group these environment variables by\nconfigured patterns, prefixes, suffixes, or combinations.\n\nSo (using the above patterns) we can parse an environment like the following:\n[source, bash]\n----\nDB_APPLES_ADDRESS=some.host\nDB_APPLES_PORT=1521\nDB_GRAPES_ADDRESS=other.host\nDB_GRAPES_PORT=1234\nDB_PEARS_ADDRESS=another.host\nDB_PEARS_PORT=4321\n----\n\n[source, go]\n----\nresult := wenv.NewEnvironmentMatcher().\n  AddGroup(wenv.NewMatchGroup(\"db\").\n    AddMatcher(wenv.NewWrappedMatcher(\"address\", \"DB_\", \"_ADDRESS\"), true).\n    AddMatcher(wenv.NewWrappedMatcher(\"port\", \"DB_\", \"_PORT\"), true),\n    true\n  ).\n  ParseEnv(wenv.SplitEnvironment(os.Environ()))\n\ndbResults := result.Get(\"db\")\n\nfor i := 0; i \u003c dbResults.Size(); i++ {\n  fmt.Println(dbResults.Get(i).FirstKey())       // APPLES|GRAPES|PEARS\n  fmt.Println(dbResults.Get(i).Value(\"address\")) // some.host|other.host|another.host\n  fmt.Println(dbResults.Get(i).Value(\"port\"))    // 1521|1234|4321\n}\n----","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxcapades%2Fgo-wildcard-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxcapades%2Fgo-wildcard-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxcapades%2Fgo-wildcard-env/lists"}