{"id":28349727,"url":"https://github.com/mkch/iter2","last_synced_at":"2025-07-06T15:08:18.372Z","repository":{"id":254899830,"uuid":"847793841","full_name":"mkch/iter2","owner":"mkch","description":"Go iter utilities.","archived":false,"fork":false,"pushed_at":"2025-04-22T04:33:51.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T01:56:18.472Z","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/mkch.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-26T14:59:38.000Z","updated_at":"2025-04-22T04:33:54.000Z","dependencies_parsed_at":"2024-08-26T22:11:13.899Z","dependency_job_id":"edb2277a-f483-4294-ab8c-5969b2af700e","html_url":"https://github.com/mkch/iter2","commit_stats":null,"previous_names":["mkch/iter2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mkch/iter2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fiter2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fiter2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fiter2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fiter2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkch","download_url":"https://codeload.github.com/mkch/iter2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fiter2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261237748,"owners_count":23128843,"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-05-27T20:10:58.722Z","updated_at":"2025-07-06T15:08:18.366Z","avatar_url":"https://github.com/mkch.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iter2\n\n Go iter utilities.\n\n1. Operations of iterator:\n\n    Zipping two Seqs to one Seq of pairs:\n\n    ```go\n    func ExampleZip() {\n        ks := []int{1, 2, 3}\n        vs := []string{\"one\", \"two\", \"three\"}\n\n        type pair struct {\n            N   int\n            Str string\n        }\n\n        s := slices.Collect(iter2.Zip(slices.Values(ks), slices.Values(vs), func(i int, s string) pair { return pair{i, s} }))\n        fmt.Println(s)\n        // Output: [{1 one} {2 two} {3 three}]\n    }\n    ```\n\n    Zipping tow Seqs to one Seq2:\n\n    ```go\n    func ExampleZip2() {\n        ks := []int{1, 2, 3}\n        vs := []string{\"one\", \"two\", \"three\"}\n        zipped := iter2.Zip2(slices.Values(ks), slices.Values(vs))\n        m := maps.Collect(zipped)\n        for k, v := range m {\n            fmt.Println(k, v)\n        }\n        // Unordered output:\n        // 1 one\n        // 2 two\n        // 3 three\n    }\n    ```\n\n    Concating 2 Seqs:\n\n    ```go\n    func ExampleConcat() {\n        seq1 := slices.Values([]int{1, 2, 3})\n        seq2 := slices.Values([]int{4, 5})\n        seq := iter2.Concat(seq1, seq2)\n        fmt.Println(slices.Collect(seq))\n        // Output:\n        // [1 2 3 4 5]\n    }\n    ```\n\n2. Map DB rows:\n\n    ```go\n    import (\n        \"database/sql\"\n        _ \"modernc.org/sqlite\"\n        // and more\n    )\n\n    func ExampleAllRows_tableStruct() {\n        db, err := sql.Open(\"sqlite\", \":memory:\")\n        if err != nil {\n            panic(err)\n        }\n        q := `\n    create temp table users (id integer, name text); -- Create temp table for queries.\n    insert into users values (1, \"User1\"); -- Populate temp table.\n    insert into users values (2, \"User2\");\n    insert into users values (3, \"User3\");\n\n    -- First result set.\n    select * from users;\n    `\n        type User struct {\n            ID   int\n            Name string\n        }\n\n        users := slices.Collect(\n            iter2.Map(\n                iter2.MustAllRows(db.Query(q)), func(row iter2.Row) (user User) {\n                    row.Scan(\u0026user.ID, \u0026user.Name)\n                    return\n                }))\n        fmt.Println(users)\n        // Should output:\n        // [{1 User1} {2 User2} {3 User3}]\n    }\n    ```\n\nMore [examples](https://pkg.go.dev/github.com/mkch/iter2#pkg-examples) here.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkch%2Fiter2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkch%2Fiter2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkch%2Fiter2/lists"}