{"id":51886859,"url":"https://github.com/owainlewis/functional-go","last_synced_at":"2026-07-25T22:01:33.307Z","repository":{"id":57631076,"uuid":"161837034","full_name":"owainlewis/functional-go","owner":"owainlewis","description":"Small, generic functional helpers for modern Go.","archived":false,"fork":false,"pushed_at":"2026-07-05T20:32:52.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-07-05T22:11:22.768Z","etag":null,"topics":["collections","functional-programming","generics","go","golang","higher-order-functions","iterators"],"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/owainlewis.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-12-14T20:27:41.000Z","updated_at":"2026-07-05T20:32:54.000Z","dependencies_parsed_at":"2022-09-26T20:11:37.795Z","dependency_job_id":null,"html_url":"https://github.com/owainlewis/functional-go","commit_stats":null,"previous_names":["owainlewis/functional-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/owainlewis/functional-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainlewis%2Ffunctional-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainlewis%2Ffunctional-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainlewis%2Ffunctional-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainlewis%2Ffunctional-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owainlewis","download_url":"https://codeload.github.com/owainlewis/functional-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owainlewis%2Ffunctional-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35894020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-25T02:00:06.922Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["collections","functional-programming","generics","go","golang","higher-order-functions","iterators"],"created_at":"2026-07-25T22:01:32.789Z","updated_at":"2026-07-25T22:01:33.276Z","avatar_url":"https://github.com/owainlewis.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# functional-go\n\nSmall, boring functional helpers for modern Go.\n\n`functional-go` gives you the helpers Go developers reach for most often:\n`Map`, `Filter`, `Reduce`, `Find`, `Any`, `All`, `GroupBy`, `Unique`, and lazy\n`iter.Seq` pipelines.\n\nIt is intentionally not a lodash clone. It is a tiny package with no\ndependencies, no reflection, no code generation, and no chaining DSL.\n\n## Why use this\n\nUse this when a small helper makes the code clearer than a hand-written loop.\n\nDo not use this when a loop is simpler. Go loops are good.\n\n## Compared with lo\n\n[`samber/lo`](https://github.com/samber/lo) is a large lodash-style toolkit.\nUse it when you want a broad utility package.\n\nUse `functional-go` when you want a smaller dependency with a stricter shape:\n\n- Core helpers only.\n- Standard-library-style names.\n- Lazy `iter.Seq` helpers.\n- No reflection.\n- No transitive dependencies.\n- Benchmarks against plain loops.\n\n## Install\n\n```sh\ngo get github.com/owainlewis/functional-go\n```\n\n## Slice helpers\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\tfunctional \"github.com/owainlewis/functional-go\"\n)\n\nfunc main() {\n\tnums := []int{1, 2, 3, 4, 5}\n\n\tout := functional.Map(functional.Filter(nums, func(n int) bool {\n\t\treturn n \u003e 2\n\t}), func(n int) int {\n\t\treturn n * 10\n\t})\n\n\tfmt.Println(out)\n}\n```\n\nOutput:\n\n```text\n[30 40 50]\n```\n\n## Iterator helpers\n\nGo 1.23 added standard iterator support with `iter.Seq`.\n\nUse the `Seq` helpers when you want a lazy pipeline.\n\n```go\nnums := slices.Values([]int{1, 2, 3, 4, 5})\n\nout := functional.Collect(functional.Take(functional.MapSeq(functional.FilterSeq(nums, func(n int) bool {\n\treturn n \u003e 2\n}), func(n int) int {\n\treturn n * 10\n}), 2))\n\nfmt.Println(out)\n// [30 40]\n```\n\n## API\n\nSlice helpers:\n\n- `Map`\n- `Filter`\n- `Reject`\n- `Reduce`\n- `FlatMap`\n- `Partition`\n- `Find`\n- `Any`\n- `All`\n- `Contains`\n- `GroupBy`\n- `IndexBy`\n- `Unique`\n- `UniqueBy`\n\nMap helpers:\n\n- `Keys`\n- `Values`\n- `Entries`\n\nIterator helpers:\n\n- `MapSeq`\n- `FilterSeq`\n- `RejectSeq`\n- `ReduceSeq`\n- `FlatMapSeq`\n- `FindSeq`\n- `AnySeq`\n- `AllSeq`\n- `Collect`\n- `Take`\n\n## Design\n\nOpinion [high]: This library should stay small.\nFlip fact: If the Go standard library adds `Map` and `Filter`, this package\nshould probably become unnecessary.\n\nRules:\n\n- Keep names plain.\n- Prefer standard library shapes.\n- Keep helpers generic and allocation-conscious.\n- Never use reflection.\n- Never add dependencies.\n- Add benchmarks for helpers that allocate or process slices.\n\n## Performance\n\nThe helpers are thin wrappers around loops. Benchmarks compare them to plain\nloops so users can make an honest call.\n\nRun:\n\n```sh\nmake bench\n```\n\nExpected tradeoff:\n\n- Slice helpers should be close to equivalent hand-written loops.\n- Iterator helpers trade some overhead for lazy pipelines and early stop.\n- If a loop is clearer or faster in hot code, use the loop.\n\nCurrent local benchmark shape on an M1 Max:\n\n- `Map`: same allocation profile as a plain loop.\n- `Filter`: same allocation profile as a plain loop.\n- `Reduce`: zero allocations, same as a plain loop.\n- `Seq` pipeline: more overhead than a fused loop, but lazy and composable.\n\n## Development\n\n```sh\nmake fmt\nmake test\nmake bench\n```\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowainlewis%2Ffunctional-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowainlewis%2Ffunctional-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowainlewis%2Ffunctional-go/lists"}