{"id":37195537,"url":"https://github.com/wanglihui/slicer","last_synced_at":"2026-01-14T22:44:13.090Z","repository":{"id":57643122,"uuid":"437875049","full_name":"wanglihui/slicer","owner":"wanglihui","description":"golang generate slice Map Filter GroupBy OrderBy and so on","archived":false,"fork":false,"pushed_at":"2022-01-07T12:26:50.000Z","size":28,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T08:46:46.136Z","etag":null,"topics":["array","go","golang","slice","utils"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wanglihui.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":"2021-12-13T13:01:53.000Z","updated_at":"2023-09-04T15:38:15.000Z","dependencies_parsed_at":"2022-08-30T04:53:02.575Z","dependency_job_id":null,"html_url":"https://github.com/wanglihui/slicer","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/wanglihui/slicer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanglihui%2Fslicer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanglihui%2Fslicer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanglihui%2Fslicer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanglihui%2Fslicer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wanglihui","download_url":"https://codeload.github.com/wanglihui/slicer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanglihui%2Fslicer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"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":["array","go","golang","slice","utils"],"created_at":"2026-01-14T22:44:12.109Z","updated_at":"2026-01-14T22:44:13.081Z","avatar_url":"https://github.com/wanglihui.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slicer\n\n[中文说明](./README_CN.md)\n\nuse go generate to generate slice helper code. like map, find, groupby, orderby, find, first and so on .\n\n### Usage\n\n```golang\n//go:generate go run github.com/wanglihui/slicer -type PackageItem\n```\n- type is struct type\n\n```bash\ngo generate ./...\n```\n\nnow go generate output code like \nyou can use Map Find Filter OrderBy and so on...\n\n```golang\n// packageitem_slice.gen.go\npackage packageitem\n\ntype PackageItem interface{}\n\ntype PackageItemSlice []PackageItem\n\ntype PackageItemFilterFn func(item PackageItem, idx int) bool\n\nfunc (items PackageItemSlice) Filter(fn PackageItemFilterFn) PackageItemSlice {\n\trets := make(PackageItemSlice, 0)\n\tfor idx, item := range items {\n\t\tif b := fn(item, idx); b {\n\t\t\trets = append(rets, item)\n\t\t}\n\t}\n\treturn rets\n}\n\nfunc (items PackageItemSlice) OrderBy(fn PackageItemCompareFn) PackageItemSlice {\n\treturn _PackageItemQuickSort(items, 0, len(items)-1, fn)\n}\n\ntype PackageItemFindFn func(item PackageItem) bool\n\nfunc (items PackageItemSlice) Find(fn PackageItemFindFn) *PackageItem {\n\tfor _, item := range items {\n\t\tif b := fn(item); b {\n\t\t\treturn \u0026item\n\t\t}\n\t}\n\treturn nil\n}\n// and so on\n\n```\n\n```golang\n//main.go\n\n// Map\nPackageItemSlice.Map(func(item PackageItem) interface{} {\n    return item.Name\n})\n// Find one\nitem := PackageItemSlice.Find(func(item PackageItem) *PackageItem {\n    return \u0026item.Age \u003e 10\n})\n\n// Filter\nitems := PackageItemSlice.Filter(func(item PackageItem) bool {\n    return item.Age \u003c 10\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanglihui%2Fslicer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanglihui%2Fslicer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanglihui%2Fslicer/lists"}