{"id":13564991,"url":"https://github.com/vtashkov/pair","last_synced_at":"2025-04-03T22:30:24.712Z","repository":{"id":57704684,"uuid":"498406869","full_name":"vtashkov/pair","owner":"vtashkov","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-31T16:11:43.000Z","size":3,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-04T18:45:42.748Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vtashkov.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":"2022-05-31T16:07:19.000Z","updated_at":"2023-03-28T17:14:08.000Z","dependencies_parsed_at":"2022-09-26T21:20:13.849Z","dependency_job_id":null,"html_url":"https://github.com/vtashkov/pair","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtashkov%2Fpair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtashkov%2Fpair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtashkov%2Fpair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtashkov%2Fpair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vtashkov","download_url":"https://codeload.github.com/vtashkov/pair/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247089627,"owners_count":20881805,"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-08-01T13:01:38.945Z","updated_at":"2025-04-03T22:30:24.419Z","avatar_url":"https://github.com/vtashkov.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# pair\n\n## Description\nThis package provides generic KeyValue pair, along with couple of useful methods. It is dead simple as code and have 100% code coverage.\n\n## Motivation\nIn my personal project I came across a situation, where I had 2 modules, which I didn't want to depend on each other. In module A I used \"dependency injection\", which I implemented as an interface that module B should (implicitly) fulfil. The methods of the interface returned list of key-value pairs. In that case using ad-hoc `string {key string; value string}` in both places couldn't work, becayse they are seen by the compiler as different types. Thus, in order not to introduce dependancy between them, I needed both the interface in module A and the implementation in module B to depend on the same struct defined somewhere in third module. It seemed excessive to me to introduce a third module only for such a generic thing in this specific project, so coming from the C# world, I decided to create a separate package that basically copies the functionality of C#'s KeyValuePair type.\n\n## Usage\n\n### Creating KeyValue pair\n\n`kvp := pair.KeyValue[string, string]{Key: \"key\", Value: \"value\"}`\n\nand then simply\n\n`kvp.Key` will give you \"key\" and `kvp.Value` will give you \"value\", as one might expect\n\n### Deconstructing\n\nFollowing C# lead, there is `Deconstruct` method:\n\n`key, value := kvp.Deconstruct()`\n\n### String\n\n`kvp.String()` will give you `{key value}`\n\n## About me\nWritten by Victor Tashkov \u003cvtashkov@gmail.com\u003e\nPublished with MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtashkov%2Fpair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvtashkov%2Fpair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtashkov%2Fpair/lists"}